Looking for:


Microsoft visual studio 2010 professional tutorial pdf free - http://replace.me

Click here to ENTER
































































No prior knowledge is necessary. Summary What you learned in this chapter were essential skills for upcoming chapters in the rest of the book.

DEFAULT
DEFAULT


  • Sony vegas pro 12 online freefree
  • Sony vegas pro 11 crack 32 bit serial number free


  • (PDF) Microsoft Visual Studio - A Beginners Guide | Md. Jaber Al Islam - replace.me.http://replace.me



    As you work with VS, the Status bar changes in a context-sensitive way to give you information specific to the task you are working on. For example, the editor displays line, column, and other information pertaining to the status of the editor. Figure shows the Solution Explorer with these three icons on its title bar at the top-right corner. The Close icon allows you to close a window.

    The following sections describe how use these title icons to manipulate these windows through expanding and collapsing, docking, floating, tabbing, and closing and opening. Chapter 1: Introducing Visual Studio 17 Figure Window title bar icons Expanding and Collapsing Windows Hovering over the Toolbox tab will expand the Toolbox and display a set of three icons in the title bar of the Toolbox window: Window Position down arrow , Hide pin , and Close cross.

    You can see what the Toolbox window looks like when expanded in Figure ; the pin in the Hide icon is sideways and the vertical tab still appears in the left margin. For any collapsed window, such as the Toolbox, you can expand that collapsed window and click the Hide pin icon to pin the window, which will make the window layout similar to the Solution Explorer.

    Figure shows the pinned window; the pin in the Hide icon above the Auto Hide tooltip is vertical and you no longer see the Toolbox tab in the left margin. Clicking the Hide icon on any expanded window will cause the window to collapse and display as a tab, similar to the Toolbox. Another way to collapse a window is by selecting the Auto Hide option on the Window Position down arrow menu. Docking Windows The Dock option displays the window in an open docked position, similar to the Solution Explorer in Figure You can move a docked window to any position in the work area.

    To move a docked window, select its title bar and drag the window out of its current position. The shadow of the window will show what the new location will be whenever you drag a window into a docking zone.

    Dropping the window into the docking zone will move the window from its old docking zone into the new docking zone. Alternatively, you can double-click on the title bar. Figure shows the Toolbox floating over other windows. For example, if the Toolbox is set as Dock As Tabbed Document, it will become a tabbed document in the same group as the Start window, as shown in Figure TIP Position windows in a way that makes you most productive.

    So, trying to drag-and-drop between two tabbed document windows can be cumbersome. To change a window from a tabbed document, select the tab and drag the window away from the other documents, making it a floating window.

    Another way to close the window is by selecting the Hide option from the Window Position icon menu. Reopening a window depends on what type of window it is: VS or Project Item.

    If the window is from VS, you can re-visit the View menu and select the window you need to open. Alternatively, you can use a keyboard shortcut key to open a window. These shortcut keys for the windows are displayed on the right side of the menu item in the View menu. Other windows are for project items in the Solution Explorer. In most cases, you would re-open a project item by locating it in the appropriate project of Solution Explorer and double-clicking it.

    You can now manipulate windows, customizing the layout of your VS environment as you need. This section will explain how to modify your settings and achieve each of these goals. From Figure , you can see the options to Export, Import, and Reset settings. The following sections explain each of these options. This could also be useful if you planned to make significant changes to your settings and wanted a backup in case you wanted to revert to previous settings.

    There is a tree of options you can choose from to determine what settings to export. The warning sign indicates settings that you might not want to export for personal or security reasons. Notice that the default filename includes the date, which could be helpful if you ever need to restore settings. Click Finish, which will perform the export and show you the Complete window in Figure after the export operation is done. Click Close to close the window. With an exported settings file, you or another person can perform an import with that file, as described in the next section.

    You can choose not to back up also. As shown in Figure , you can import some of the predefined settings that are part of VS under the Default Settings branch or import custom settings under the My Settings branch.

    After selecting a settings file, click Next, which brings you to the Choose Settings To Import window shown in Figure The Choose Settings To Import window allows you to specify only those settings that you want in your environment.

    It will only update the settings checked in Figure All of your other current settings, those that are unchecked in Figure , will not be changed. Click Finish to begin the import operation. Another settings option is to reset your current settings to one of the VS default options, explained next. Resetting All Settings You could reset settings if you wanted to restore the default settings in VS or if you wanted to switch between default VS settings.

    For this book, I switched between default settings for VB and C to ensure the environment settings were appropriate for whichever language I was discussing. Choose the Reset All Settings option and click Next. Each of these default settings are the same as what you selected during installation, previously shown in Figure and the Default Settings branch of Figure Choose a setting and click Finish, which starts the reset operation.

    Earlier in the chapter, we discussed projects very lightly, but we will gradually dig deeper as this book progresses. The next section takes you a little bit further by describing what project types are available in VS.

    The following discussion will show how to find what project types are available and describe what those project types are. To see what projects are available, select File New Project, as shown in Figure Chapter 1: Introducing Visual Studio 31 Figure Reset Complete window In addition to a new project, Figure shows that you can create a new Web site, just open a file for editing, or open a wizard that creates a new project from existing files.

    Windows Forms is an older desktop GUI technology. The new desktop GUI technology for. Chapter 1: Introducing Visual Studio 33 Figure New Project window Other windows projects include Windows Services, which are applications that are always on and run as a service in the background without a GUI, Class Libraries for holding reusable code often referred to as middleware, and Control Libraries for holding graphical controls that can be dragged-and-dropped from the Toolbox onto a visual designer within VS.

    An ASP. Web Services are reusable components that you can call from across the Internet. An important feature of Web Services is that they use ubiquitous protocols to enable code from any platform to call them, facilitating integration among heterogeneous computing systems. Dynamic Data projects offer a quick way to build a working Web site, based on an existing database schema. An Office project allows you to automate Office applications through. It is closely associated with Office applications and managing workgroup collaboration.

    For example, you can write stored procedures and functions in either C or VB and have the benefit of the. NET Framework in your code. Summary By knowing the benefits of VS, you have an appreciation for what VS can do for you, increasing your productivity through automatically generated code, rapid coding and visual design, and extensibility.

    You should be able to install VS, choosing the options that prepare the environment specifically for the work you want to do. Having grown acquainted with each of the major features of the IDE, you can open VS and find the features that you need.

    NET platform supports several different programming languages. Since all of the languages run on the same platform and share the same class libraries, language choice becomes a personal choice of preference. In other words, you can accomplish the same tasks, regardless of what programming language you use. NET, you have a choice of language but retain the same benefits of having all of the features of.

    NET available to you. NET VB. C and VB are the two most popular. NET programming languages and have the greatest support in VS. Therefore, this book uses both C and VB in all examples. While you may choose one of these languages as your favorite, there is great benefit in knowing both. Most of what is written online, in magazines, and in books contains examples for either C or VB, and sometimes, but not always, both. You might not want to miss great content because of a limited language choice.

    Chapter 1 danced around projects and what is available. This is the first chapter of three that covers language syntax, combining each language feature with tips on how VS helps you code. Starting a Bare-Bones Project Chapter 1 described the project types that you can create. This chapter takes you a step further; actually creating a project. Because the primary focus of this chapter is on learning C and VB, the project type will be a Console application. A Console application is very simple, allowing you to read and write text from and to the Command Prompt window.

    Your first task is to select Console Application as the program type. Then set the program name to FirstProgram and specify a location of your choice for where the project will be created. Other features of the New Project window include the ability to specify the. NET Framework version, sorting options, icon size options, and a search capability. Choosing a shorter path helps alleviate these problems. NET Framework is the set of class libraries, runtime, and languages that is the development platform supported by VS.

    VS allows you to target multiple versions of the. NET Framework, including versions 2. VS will compile your code against the version you choose. NET features. The primary reason for using an earlier version is if you must perform work on code that is already written for an earlier version of. The sorting and searching features to the right of this selection enable you to find project types in different ways, whichever is most comfortable for you.

    Clicking OK will produce a Console application project in the programming language you chose, which you can see in the Solution Explorer, shown in Figure The Solution Explorer in Figure contains a solution, which is a container for multiple projects.

    Under the solution is the FirstProgram project. Within the FirstProgram project are project items, such as files and settings. NET: Basic Syntax 39 into a project depend on the project type. Of particular interest in the FirstProgram project is the file named Program. VS will create skeleton code using built-in templates for most project types that you create.

    Listing Console application skeleton code C : using System; using System. Generic; using System. Linq; using System. It is there to give you a head start on writing your program. What you now have is a whole computer program.

    Looking at the whole program, you can see that there are sets of nested curly braces in the C code. The VB code has Module and Sub with corresponding End identifiers to indicate the boundaries of a block.

    The braces in C code always come in pairs and define a block. The following explanation works from the inside out to help you understand what this code means. The Main Method The innermost block of the C code is the static void Main string[] args definition, which is called a method. The method in VB is called Sub Main and is identical in purpose. You can think of methods as actions where you, as the method author, tell the computer what to do. The name of this particular method is Main, which is referred to as the entry point of the program, the place where a Console application first starts running.

    Another way of thinking about Main is that this is the place your computer first transfers control to your program. Therefore, you would want to put code inside of Main to make your program do what you want it to.

    In C , Main must be capitalized. Although VS capitalizes your code for you if you forget to, VB is not case-sensitive. Capitalization is a common gotcha, especially for VB programmers learning C.

    In C , methods can return values, such as numbers, text, or other types of values, and the type of thing they can return is specified by you right before the method name. Since Main, in the C example, does not return a value, the return type is replaced with the keyword void. Methods can specify parameters for holding arguments that callers pass to the method.

    In the case of Main, the parameter is an array of strings, with a variable name of args. The args parameter will hold all of the parameters passed to this program from the command line. One more part of the C Main method is the static keyword, which is a modifier that says there will only ever be a single instance of this method for the life of the program.

    Think about a company that has multiple customers. NET: Basic Syntax 41 that belong to each instance. If an object such as Customer has methods that belong to each instance, those methods are not static. However, if the Customer object type has a method that is static, then there would only be a single copy of that method that is shared among all Customer objects.

    For example, what if you wanted to get a discount price for all customers, regardless of who the customer is; you would declare a static method named GetCustomerDiscount. However, if you wanted information that belonged to a specific customer, such as an address, you would create an instance method named GetAddress that would not be modified as static.

    VB uses the term shared, which has the same meaning as static. Modules are inherently shared, and all module methods must be shared. Therefore, the VB Main method is shared. In C , the curly braces define the begin and end of the Main method. Next, notice that the C Main method is enclosed inside of a set of braces that belong to something called a class that has been given the name Program.

    The VB Main method is enclosed in something called a module. The Program Class Methods always reside inside of a type declaration. A type could be a class or struct for C or a class, module, or struct in VB. The term type might be a little foreign to you, but it might be easier if you thought of it as something that contains things. Methods are one of the things that types contain.

    In VB, you would replace Module with Class. The Program class contains the Main method. The Console application defined the skeleton code class to have the name Program. In reality you can name the class anything you want. Whatever names you choose should make sense for the purpose of the class. For example, it makes sense for a class that works with customers to be named Customer and only contain methods that help you work with customers. Classes are organized with namespaces, which are discussed next.

    The FirstProgram Namespace A namespace helps make your class names unique and therefore unambiguous. They are like adding a middle name and surname to your first name, which makes your whole name more unique.

    A namespace name, however, precedes the class name, whereas your middle name and surname follow your first or given name. This organization helps to build libraries of code where programmers have a better chance to find what they need. NET platform has a huge class library that is organized into namespaces and assemblies; this will become clearer the more you program.

    The main. NET namespace is System, which has multiple sub-namespaces. For example, guess where you can find. NET classes for working with data? Look in System. Another quick test: Where are. Try System. Another benefit of namespaces is to differentiate between classes that have the same name in different libraries.

    For example, what if you bought a third-party library that has a Customer class? Think about what you would do to tell the difference between Customer classes. The solution is namespaces, because if each Customer has its own namespace, you can write code that specifies each Customer by its namespace. Always using namespaces is widely considered to be a best practice.

    NET: Basic Syntax 43 The using directives at the top of the C part of Listing are really a shortcut that makes it easier for you to write code. For example, the System namespace contains the Console class.

    If the using System directive were not present, you would be required to write System. WriteLine instead of just Console. This was a short example, but using directives can help clean up your code and make it more readable. This section will point out a few features you will be interested in and show you how to perform customizations.

    Figure shows the editor with the Console application skeleton code from the C part of Listing Class and Member Locators The two drop-down lists, class locator and member locator, at the top of the editor are for navigating the code. If you have multiple classes in your file, you can use the class locator drop-down list on the left to select the class you want to find, and the editor will move you to the first line of that class declaration.

    However, you will have VS wizards that automatically generate code and put many classes in the same file, and the class locator is very useful if you want to find a particular class and learn about what the automatically generated code is doing.

    The member locator drop-down list on the top right contains a list of methods and other members for the class selected in the class locator. Selecting a member causes the editor to move you to the first line of that class member. The next section discusses bookmarks. Bookmarks Figure shows a bookmark on the line for the program class.

    Bookmarks allow you to navigate code quickly without manual navigation when working with multiple documents or multiple locations within the same document. Table shows a list of keyboard commands for bookmarks. The bookmark has a toolbar, which is the same toolbar that appears in VS when the editor window is active. The actions on the toolbar include the items from Table , plus the ability to move between folders. Within the Bookmark list, you can check to make a bookmark active or inactive.

    When the bookmark is inactive, previous and next navigation will not stop at the bookmark. You can change the name of the bookmark by clicking the name twice.

    The File Location and Line Number tell you where the bookmark is located. Setting Editor Options The editor is very configurable, and there are more options available than many people realize. You can view available options by selecting Tools Options to show the Options window in Figure Regarding our current discussion of the editor, this is where you can customize the coloration of code elements that appear in the editor.

    Most editor customizations are in a language-specific branch of the Options window. Figure shows the options available for C programmers. As you can see, there are very detailed settings for even how the editor automatically formats new lines and where braces appear.

    Saving Time with Snippets Snippets are important to learn because they will save you time. A snippet is a set of keystrokes that form a template for a piece of code. The code for a snippet is typically something that is common in normal programming. To use a snippet, begin typing the snippet prefix until the snippet acronym appears in the Intellisense completion list, press the TAB key twice, and fill in the snippet form while tabbing through each field.

    To start, open any code file and click to start typing in a part of the file outside of all code blocks, such as directly below any using statements but above any existing namespace statements. Type the letter n and watch the completion list go straight to the namespace element. At this point, you can press the TAB key to complete the namespace keyword. Then press TAB again to produce a template where you can fill out the highlighted fields. As shown in Figure , you would type in the Namespace name in the highlighted form field to replace MyNamespace, which is placeholder text.

    For templates with more fields, you would press the TAB key to move between fields. In the case of the namespace shown in Figure , there is only one field in the template to complete. VB offers a couple of ways to add snippets: by typing prefixes or via a pick list. To see how VB snippets work, place your carat inside of the Module1 module, underneath End Main not inside of the Main block. Another way to add VB snippets is to type a? You can navigate this pick list to find the snippet you need, as classified in one of the folders.

    VB ships with many more built-in snippets than for C. Before writing any code, you should know how Intellisense works; it is an important productivity tool that reduces keystrokes for common coding scenarios. Making Intellisense Work for You Previously, you saw how snippets work. Snippets use Intellisense to show a completion list. Intellisense is integrated into the VS editor, allowing you to complete statements with a minimum number of keystrokes.

    The following walkthrough shows you how to use Intellisense, as we add the following line to the Main method. WriteLine "Hello from Visual Studio ! Inside the braces of the Main method, type c and notice how the Intellisense window appears, with a list of all available identifiers that start with c. This list is called a completion list.

    Type o and notice that the completion list filters all but those identifiers that begin with co. This is what we want, and you only needed to type three characters to get there. The real value is in knowing that there are a lot of these detailed options available to increase your productivity. Every time you take advantage of a new VS option, you raise the notch of productivity just a little higher. Now type write and notice that both Write and WriteLine appear in the completion list.

    Now type the letter l and notice that WriteLine is the only option left in the completion list. This is because Intellisense remembers your most frequently used identifiers and will select them from the list first.

    If you continue to type, Intellisense will then highlight those identifiers with exact matches. Notice the checked option in Figure ; Intellisense preselects most recently used members, showing that this behavior is turned on by default. Save another keystroke and press the key to let VS finish the WriteLine method name.

    Referring back to Step 4, this is how you know that a period commits the current selection. You now have a program that does something; it can print a message to the console. The next section will explain how you can run this program. Running Programs In VS, you can run a program either with or without debugging. Debugging is the process of finding errors in your code. Running without debugging allows you to run the application, avoiding any breakpoints that might have been set.

    Because of the way the application is coded so far, the Command Prompt window will quickly run and close; you might miss it if you blink your eyes. To prevent this, you can add a Console. ReadKey statement below Console. WriteLine, which will keep the window open until you press any key. To understand why there are two options, think about the difference between just running a program and debugging. If you run a program, you want it to stay open until you close it.

    However, if you are debugging a program, you have most likely set a breakpoint and will step through the code as you debug. When your debugging session is over, you want the program to close so that you can start coding again right away. Now that you know how to add code to the Main method and run it, you can begin looking at the building blocks of algorithms, starting in the next section.

    Primitive Types and Expressions The basic elements of any code you write will include primitive types and expressions, as explained in the following sections. Primitive Types You can define variables in your programs whose type is one of the primitive types. Variables can hold values that you can read, manipulate, and write. There are different types of variables, and the type specifies what kind of data the variable can have. NET there are primitive types aka built-in and custom types.

    The custom types are types that you create yourself and are specific to the program you are writing. For example, if you are writing a program to manage the customers for your business, then you would create a type that could be used as the type of a variable for holding customer types. First, you need to learn about primitive types. The primitive types are part of the programming languages and built into. A primitive type is the most basic type of data that you can work with in.

    In contrast, a custom type can be made up of one or more primitive types, such as a Customer type that would have a name, an address, and possibly more bits of data that are primitive types. Table lists the primitive types and descriptions. Looking at Table , remember that C is case-sensitive and all of the primitive types are lowercase. You can also see a third column for. NET types. The following example shows how to declare a bit signed integer in both C and VB, along with the.

    Additionally, you see age defined in both C and VB using the. NET type, Int Notice that the. NET type is the same in both languages. In fact, the. NET type will always be the same for every language that runs in. Each language has its own syntax for the. NET types, and each of the language-specific types is said to alias the. NET type. The variable could be named pretty much anything you want; I chose the word result for this example.

    The type of our new variable result in the VB example is Int32, which is a primitive. You could have used the VB keyword Integer, which is an alias for Int32 instead.

    The value of result will be 38 because expressions use standard algebraic precedence. You can modify the order of operations with parentheses. Listing shows how the ternary and immediate if operators work. Otherwise, if the condition evaluates to false, the second expression, following the colon for C or after the second comma for VB, will be returned.

    NOTE In earlier versions of the VB programming language, you were required to place an underline at the end of a statement that continued to the next line. In the latest version of VB, line continuations are optional. Enums An enum allows you to specify a set of values that are easy to read in code. Type the enum in Listing The next statement uses a ternary operator to check the value of accountType, evaluating whether it is Checking.

    If so, message is assigned with the first string. Otherwise, message is assigned with the second string. Branching Statements A branching statement allows you to take one path of many, depending on a condition. For example, consider the case for giving a customer a discount based on whether that customer is a preferred customer. The condition is whether the customer is preferred or not, and the paths are to give a discount or charge the entire price.

    Two primary types of branching statements are if and switch Select Case in VB. The following sections show you how to branch your logic using if and switch statements. Expressions If statements allow you to perform an action only if the specified condition evaluates to true at runtime.

    The condition must evaluate to either a Boolean true or false. Additionally, you can have an else clause that executes when the if condition is false.

    A clause is just another way to say that an item is a part of another statement. NET: Basic Syntax 59 As shown in Figure , the template brings you to a highlighted field for specifying the condition of the if statement. For C , type the condition you want evaluated and press ENTER; the snippet completes by placing your carat within the if statement block.

    For VB, just place your cursor where you want to begin typing next. In C , the else statement snippet is similar to if. WriteLine "Name is Megan" ; break; default: Console. WriteLine "Unknown name" End Select In the C example, you can see the keyword switch with the value being evaluated in parentheses. The code to execute will be based on which case statement matches the switch value. When the program executes a break statement, it stops executing the switch statement and begins executing the next statement after the last curly brace of the switch statement.

    For the VB example, the Select Case statement uses name as the condition and executes code based on which case matches name. The Case Else code block will run if no other cases match. Switch Statement Snippets There are two scenarios for switch statement snippets: a minimal switch statement and an expanded switch with enum cases.

    However, there is a special feature of the switch snippet that makes it even more efficient to use enums, creating a case for each enum value automatically. In the following example, we use the accountType variable of the enum type BankAccount from Listing Checking: break; case BankAccount.

    Saving: break; case BankAccount. Loops You can perform four different types of loops: for, for each, while, and do. The following sections explain how loops work. For Loops For loops allow you to specify the number of times to execute a block of statements. The VB For loop initializes i as an integer, iterating repeating three times from 0 to 2, inclusive. Although i is an integer, it will be converted to a string prior to concatenation.

    The C for loop snippet template is different from previous templates in that you have two fields to fill out. First, name your indexer, which defaults to i, and then press TAB, which moves the focus to the loop size field, containing Length as the placeholder. If you like the variable name i, which is an understood convention, just press the TAB key and set the length of the loop.

    For Each Loops For each loops let you execute a block of code on every value of an array or collection. Arrays store objects in memory as a list.

    WriteLine person Next In this example, people is an array of strings that contains three specific strings of text. The block of the loop will execute three times, once for each item in the array. Each iteration through the loop assigns the current name to person. The for each loop snippet gives you three fields to complete. The var is an implicit type specifier that allows you to avoid specifying the type of item; the compiler figures that out for you, saving you from some keystrokes.

    The item field will be a collection element type. You may leave var as is or provide an explicit type, which would be string in this case.

    You can tab through the fields to add meaningful identifiers for the item and collection you need to iterate through. To execute the VB For Each snippet, type? Be careful not to create endless loops. The Console. ReadLine reads the user input, which is of type string.

    If the input is a string that contains only a capital Q, the loop will end. VB has another variation of loops that use the Until keyword, as follows: Do Console.

    For a VB Do snippet type? Figure shows an example of the Do Loop While template. Summary Working with languages is a core skill when building. NET applications. Two of the most used languages in.

    You learned about types, expressions, statements, code blocks, conditions, and branching. Additionally, you learned some of the essential features of VS for writing code, such as the code editor, bookmarks, Intellisense, and snippets. Chapter 3 takes you to the next step in your language journey, teaching you about classes and the various members you can code as part of classes. This chapter will specifically discuss the class type, which allows you to create your own custom types.

    Creating Classes Previously, you learned about the primitive types, which are built into languages and alias the underlying. You can also create your own types, via classes, which you can instantiate and create objects with. The following section explains how to create a class and then instantiate an object from it. Class Syntax To create a new custom class definition, right-click the project, select Add Class, name the class Employee for this example, and type the file extension.

    You can add members to a class, which could be events, fields, methods, and properties. A field is a variable in a class that holds information specific to that class. Listing shows how to instantiate an object of type Employee, which is your new custom type, and use it. You would put this code inside of Main or another method. The C new Employee or VB New Employee clause creates a new instance of Employee, and you can see that this new instance is being assigned to emp.

    With that new instance, via the emp variable, you can access the Employee object, including its instance members. In Listing , the FirstName field of that particular instance of Employee is assigned a string value of "Joe". Here you see that an object can contain data. Class Inheritance One class can reuse the members of another through a feature known as inheritance.

    In programming terms, we say a child class can derive from a parent class and that child class will inherit members such as fields and methods of the parent class that the parent class allows to be inherited. The following example will create a Cashier class that derives from the Employee class. To create this class, right-click the project, select Add Class, and name the class Cashier.

    Listing shows the new class and modifications for implementing inheritance. Listing Class inheritance C : using System; using System. In VB, you write the keyword Inherits, on a new line, followed by the class being derived from. Essentially, this means that Cashier has all of the same members as Employee. Listing demonstrates the benefits of inheritance. Because of inheritance, Cashier automatically inherits FirstName, and the code in Listing is perfectly legal.

    Inheritance can be thought of as specialization in the sense that, in this example, Cashier is a specialized kind of Employee. An instance of the Employee class would not be able to contain this information. NET Framework uses inheritance extensively to offer you reusable class libraries. Before using the class snippet, create a new class file by right-clicking the project, select Add New Item Code File, and name the file Manager.

    The carat will locate to the inside of the class block. Writing Methods You can divide your algorithms into blocks of code called methods. In different programming languages, methods are called functions, procedures, or subroutines. WriteLine, where WriteLine is a method of the Console class.

    A method contains one or more statements. Reasons for creating methods include the ability to modularize your code, isolate complex operations in one place, or group a common operation that can be reused in multiple places. The following sections show you how to declare and use methods.

    Listing will move the Console. Writeline statement from the Main method discussed in Chapter 2 into a new containing method and then add a statement to the Main method that calls the new method. Listing Declaring and calling a method C Program. WriteLine "Hello from a static method. WriteLine "Hello from an instance method.

    WriteLine "Hello from a shared method. In VB, shared methods are the same as static. PrintMessageStatic has a void keyword, meaning that this method does not return a value. In VB, you indicate that a method does not return a value by making it a Sub, as was done in Listing Within the method block, you can see that there is a Console. WriteLine statement.

    You can add as many statements as you need for the purpose of the method. PrintMessageShared Viewing the preceding example, which shows a statement inside of the Main method, you can see the call to Program. Notice that the class aka type that contains all the methods is named MessagePrinter. In C , a static method is called through its containing type, which is why you call PrintMessageStatic with the Program prefix.

    We discuss instance methods next. The next method, PrintMessageInstance, is an instance method; it has no static modifier. The rest of the method definition mirrors that of the PrintMessageStatic method. Using the statement new MessagePrinter creates a new instance of MessagePrinter at runtime, which is assigned to the msgPrint variable. Declaring Parameters and Passing Arguments Passing parameters to a method is a great way to make code more reusable.

    For example, what if you had a method that printed a report containing the names of all customers? Listing shows a method that takes a list of customers and prints a report with customer names. Listing Declaring a method that takes parameters C Program.

    WriteLine title ; Console. WriteLine title Console. WriteLine name Next End Sub End Class Parameters are a comma-separated list of identifiers, along with the type of each identifier, which clearly indicates what type of parameter the method is expecting. In Listing , the PrintCustomerReport method has two parameters: title of type string and customers of type string array.

    The method displays the title in the console window when you run the program, displays a blank line, and then iterates through the list, displaying each customer name to the console.

    The arguments being passed, reportTitle and customerNames, match the position and types of the parameters for PrintCustomerReport, which are of the correct types that the PrintCustomerReport method is expecting.

    In the preceding example, the calling code must provide arguments, actual data, for all parameters. However, you can specify parameters as being optional, allowing you to omit arguments for the optional parameters if you like.

    WriteLine name Next End Sub The preceding code requires callers to pass an array of customers, but it does not require a title. When writing methods, optional parameters must be listed last.

    In addition to passing arguments to methods, you can receive values returned from methods. To demonstrate the proper syntax, Listing contains a method that accepts an int and returns the squared value of that int. Calling code then assigns the return value from the method to a variable and displays the value on the console window.

    Create a new class named Calc. Listing Returning values from methods C Program. SquareInt 3 ; Console. SquareInt 3 Console. Whenever you specify a return type, the method must return something whose type is the same as the return type declared. In the preceding example, the return type is declared as int; therefore, the method guarantees that the result of the calculation is type int.

    The Main method has a couple of statements that invoke this method and display the results to the console. In the VB example, the method is now a Function. Notice how the function signature appends As Integer after the parameter list, which indicates that the return type of the function is Integer.

    NET: Types and Members 81 Coding Fields and Properties A field is a variable that is a member of a class type , as opposed to variables that are declared inside of methods, which are called local variables or locally scoped variables.

    Properties are type members that give you functionality that is a cross between fields and methods. You can read and write to a property just as you can to a field. Additionally, you can define code that runs whenever you read to or write from a property, similar to methods.

    The following sections define fields and properties. Declaring and Using Fields As stated, a field is a variable that is a member of a class or some other container, such as a struct, which is very similar to a class. To demonstrate how a field is declared and used, the example in Listing simulates a bank account that has a field of type decimal named currentBalance, which holds an account balance.

    The class has two methods: Credit and Debit. Credit increases the value of currentBalance, and Debit decreases the value of currentBalance. Listing Using fields and properties C : using System; using System. Credit m ; account. Debit 50m ; Console. CurrentBalance ; Console. When variables like accountBalance are declared as class members, as opposed to local variables that are declared inside of method blocks, they are called fields.

    The accountBalance is type decimal, which is a good choice for holding financial values. The accountBalance field has a private modifier, which means that it can only be used by members of the same class. The implementations of Credit and Debit, respectively, increase and decrease the value of accountBalance. Main invokes Credit and Debit to change the value of the accountBalance field.

    Additionally, Main displays the value of accountBalance in the console window through a property named CurrentBalance. The next section explains how the CurrentBalance property works. Declaring and Using Properties Properties are class members that you use just like a field, but the difference is that you can add specialized logic when reading from or writing to a property.

    When you read from a property, only the get accessor code executes, and the set accessor code only executes when you assign a value to a property. In the preceding example, the get accessor returns the value of currentBalance with no modifications.

    If there were some logic to apply, like calculating interest in addition to the current balance, the get accessor might have contained the logic for that calculation prior to returning the value. The set accessor does have logic that checks the value to see if it is less than zero, which could happen if a customer overdrew his or her account. If the value is less than zero, then you could implement logic to charge the customer a fee for the overdraft.

    The value keyword contains the value being assigned to the property, and the previous set accessor assigns value to the accountBalance field. The following statement from the Main method in Listing reads from CurrentBalance, effectively executing the get accessor, which returns the value of currentBalance: C : Console. CurrentBalance ; VB: Console. WriteLine statement will print the value read from CurrentBalance to the command line.

    Since this is so common, you can save syntax by using an automatic property, as shown in Listing Behind the scenes, the compiler produces the expanded version where the backing field is guaranteed to have a unique name to avoid conflicts. Do not overlook that when you use automatic properties, you cannot add your own code that runs inside the get or set accessors.

    A C property snippet template creates an automatic property by default, but the VB snippet template is a normal property with full get and set accessors. After learning how to create classes and use class instances, also known as objects, you learned how to add fields, methods, and properties to your class definition.

    The methods discussion was more in-depth, showing you how to define parameters and return values. You also learned how to define both auto-implemented and normal properties, and you learned a little about class inheritance. The next chapter moves you up a level in language skills by showing you how to create another type, called an interface. This chapter rounds out the bare essentials of what you need to know with delegates and events, interfaces, and a quick introduction to arrays and generics.

    Understanding Delegates and Events Sometimes you need to write flexible code that performs general operations. For example, when the designers of the.

    NET Framework created user interfaces, they added reusable controls, such as buttons, list boxes, and grids. For example, how would anyone know what we wanted our code to do when a user clicks a button on the user interface?

    So, these controls have interaction points built in so that they can communicate with your program; these interaction points are called events.

    These events fire whenever a user performs an action such as a button click or a list box selection. We write code to hook up these events to some other code in our program that we want to run when that event happens, such as when the user clicks a button, and this is what delegates are used for. An event defines the type of notifications that a object can provide, and a delegate allows us to connect the event to the code we want to run.

    This section will show you the mechanics of how delegates and events work, but you should understand that the mechanics may seem somewhat abstract at first. NET: Intermediate Syntax 91 The next section will add more logic to the set accessor in CurrentBalance in the next listing and raise an event for the calling code. Events An event is a type of class member that allows your class or class instance to notify any other code about things that happen within that class.

    To help you understand the use of events, this section will associate an event with the accountBalance of an account. Listing is a modified version of Listing from Chapter 3. It additionally has an event and logic that raises the event. To see how an event can be useful, consider a program that uses a class that manages accounts. There could be different types of accounts, such as checking or savings. If a customer performs an overdraft, the consequences probably vary by what type of account is being used.

    Therefore, you can give the account class an event that will fire off a notification whenever an overdraft occurs. Then, within your specialized checking account class instance, for example, you can register something called an event handler so that the instance of the class knows each time the overdraft event occurs via the handler. In Listing , the CurrentBalance property is modified to raise or fire off an OverDraft event whenever the assigned value is less than 0. The Main method hooks up another method that will run whenever that event occurs.

    Listing Event demo C : using System; using System. The OverDraft event is public and is declared with the event keyword. It defines the communication contract that must be adhered to by any code that wishes to listen for the event to fire. Look at the set accessor of the CurrentBalance property, inside of the if statement where it determines if value is less than 0. The C example has another if statement to see if the OverDraft event is equal to null.

    In C when an event is equal to null, it means that nothing has subscribed to be notified by the event—in essence, no other code is listening. However, when the C event is not null, then this indicates that some code somewhere has hooked up a method to be called when the event fires. That method is said to be listening for the event.

    So, assuming that the caller has hooked up a method, the OverDraft event is fired. This check for null is important. If nothing is listening for the event and our code knows this to be the case when the event is null , and we raise or fire the event by calling OverDraft this, EventArgs. Empty , an error null reference exception would occur at runtime whenever a value is set into the CurrentBalance property. The arguments to the C event mean that the current object which is the Program class instance , this, and an empty EventArgs will be passed as the event message to any other methods that were hooked up to this event.

    It is interesting to note that many methods can be hooked up to your event or none at all , and each will be notified in turn when your event fires.

    You should start to see that events really are a form of almost spontaneous communication within your program. The preceding discussion talked about a method that is hooked up to the event and executes receives a message whenever the event fires. Size : Getting started with MVC3. Description : This tutorial will teach you the basics of building an ASP. Size : 1. PDF file. Data Acquisition in C. Advanced PowerPoint Description : You can animate the text, pictures, shapes, tables, SmartArt graphics, and other objects in your Microsoft PowerPoint presentation to give them visual effects, including entrances, exits, changes in size or color, and even movement.

    Beginners Guide to C and the. Description : This book is for beginners wanting to get started on. NET Micro Framework. No prior knowledge is necessary. The book covers the basics of. Accessibility Features In Microsoft Excel Description : You will learn how to control the visual appearance of your spreadsheet. Additionally, best practices and effective spreadsheet structure are also covered to help you when using Excel.

    Microsoft Excel Level 1. Description : This tutorial includes an introduction to the Microsoft Office interface, and covers the various aspects of creating, formatting, editing, saving, and printing a document in Word OOP in Visual Basic. Microsoft Word Level 1. Description : PDF tutorial It includes an introduction to the Microsoft Office interface, and covers the various aspects of creating, formatting, editing, saving, and printing a document in Word Portable Visual Basic.

    Description : Download free Visual Basic. Introduction to Visual Basic. Description : Download a Introduction to Visual Basic. Visual Basic and. NET Gadgeteer. Size : 3. Visual C Programming Basics. Daniel Liang Size :



  • Windows server 2016 standard wsl free
  • Logic pro x 10.4 high sierra free
  • Capture one pro 12 whats new free


  • DEFAULT

    DEFAULT

    Microsoft visual studio 2010 professional tutorial pdf free. Microsoft Visual Studio 2010 - A Beginners Guide



    NET Framework multitargeting support, where you can work with any version of. Cleaning is a tool to help you know whether a project is really being built.

  • Pc games for windows 10 home free
  • Windows 10 pro nach enterprise free
  • Microsoft office 2013 jalan tikus free
  • Microsoft visio 2013 unlicensed product crack free
  • Microsoft office 2013 service pack 2 free


  • DEFAULT
    DEFAULT

    http://replace.me - Microsoft visual studio 2010 professional tutorial pdf free



    Open source. A framework for building web apps and services with. NET and C. Get Started. Blazor is a feature of ASP. Blazor gives you real. NET running in the browser on WebAssembly. Learn about Blazor. NET is a developer platform made up of tools, programming languages, and libraries for building many different types of applications.

    NET extends the. NET developer platform with tools and libraries specifically for building web apps. Dig deeper: What is ASP. NET performs faster than any popular web framework in the independent TechEmpower benchmarks. Data sourced from official tests available at TechEmpower Round NET supports industry standard authentication protocols. NET provides a built-in user database with support for multi-factor authentication and external authentication with Google, Twitter, and more.

    NET is open source on GitHub, with over , contributions and 3, companies already contributing. Join the. NET community. You can also deploy to any major cloud platform, your own Linux or Windows servers, or one of many hosting providers. Host for free with Azure. Our step-by-step tutorial will help you get ASP. NET running on your computer. Home ASP.

    Let's Learn. Did you miss Let's Learn. Watch the session on demand. Watch on-demand. NET Free. Real-time Enable bi-directional communication between server and client, in real-time.

    Microservices Create independently deployable microservices that run on Docker containers. What is ASP. Learn ASP. NET has to offer with our tutorials, video courses, and docs. Learn to use ASP. Fast and scalable ASP. Build secure apps ASP. NET websites for free with Microsoft Azure.

    Ready to Get Started? Follow us.



  • ms office 2010 windows 7 32 bit free
  • endnote x7 for windows 10 free




  • DEFAULT
    DEFAULT

    1 comment
    Mezisar post a comment:

    Download the latest from Windows, Windows Apps, Office, Xbox, Skype, Windows 10, Lumia phone, Edge & Internet Explorer, Dev Tools & more. Visio shapes are ready-made objects that you drag onto your drawing page — they are the building blocks of your diagram.. When you drag a shape from the Shapes window onto your drawing page, the original shape remains on the stencil. That original is called a master replace.me shape that you put on your drawing is a copy — also called an instance — of that .