Visual studio 2008 beginners guide pdf




















This book is a comprehensive computer programming tutorial that teaches programming, logical thinking, data structures and algorithms, problem solving and high quality code with lots of examples in C. Easily get started programming using the ultra-versatile C 7 and Visual Studio The new C 7 and Visual Studio updates feature a number of new tools and features that streamline the workflow, simplify the code, and make it easier than ever to build high-quality apps.

This book walks you through everything you need to know, starting from the very basics, to have you programming in no time.

To browse Academia. Skip to main content. By using our site, you agree to our collection of information through the use of cookies. To learn more, view our Privacy Policy. Log In Sign Up. Download Free PDF. In the recent period more and more people are interested in taking visual basic courses and tutorials. The course includes tutorials that is adjusted for beginner level users which make it easy to learn and actually quite fun and entertaining.

Learning has never been so simple and easy. The best part is that our list of computer courses is growing every day. We know that these useful tutorials are updated and upgraded all the time, so we are adding new courses and tutorials as soon as possible. In Program. Select the green Start button next to CalculateThis to run your program.

Now that you've created an app, you might want to add it to a Git repository. We've got you covered. Git is the most widely used modern version control system, so whether you're a professional developer or you're learning how to code, Git can be very useful. There, you can find cheat sheets, a popular online book, and Git Basics videos.

To associate your code with Git, you start by creating a new Git repository where your code is located. The repository name auto-populates based on your folder location. By default, your new repository is private, which means you're the only one who can access it. Whether your repository is public or private, it's best to have a remote backup of your code stored securely on GitHub. Even if you aren't working with a team, a remote repository makes your code available to you from any computer.

You can use this icon to pull any incoming commits or push any outgoing commits. You can also choose to view these commits first. The second icon with the pencil shows the number of uncommitted changes to your code. You can select this icon to view those changes in the Git Changes window. To learn more about how to use Git with your app, see the Visual Studio version control documentation.

Visual Basic is a type-safe programming language that's designed to be easy to learn. Visual Studio is an integrated development suite of productivity tools for developers. Think of it as a program you can use to create programs and applications.

NET Core is the evolutionary next step of the. NET Framework. Where the. NET Framework allowed you to share code across programming languages,.

NET Core adds the ability to share code across platforms. Even better, it's open source. Both the. NET Framework and. NET Core include libraries of prebuilt functionality and a common language runtime CLR , which acts as a virtual machine in which to run your code.

Build a library with Visual Basic and the. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. 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. The next section explains how to use a delegate to specify what this method is. The delegate specifies the allowable signature, the number of arguments, and their types, of a method that is allowed to be hooked up to the event as a listener or handler.

NET Framework class library, and it, by definition, specifies that any methods hooked up to the OverDraft event must define two parameters: an object of any type and an EventArgs class. EventHandler also specifies that the method does not return a value explicitly. If you remember, the delegate type of OverDraft is Eventhandler, which defines the precise message contract. The next piece of the puzzle is the method to be notified when the event happens. This method is the parameter given to the new EventHandler delegate instance.

Think about the GUI code that has reusable components, like buttons and list boxes. You do this through events: a Click event for the button and a SelectedItemChanged for the list box.

This is the standard way that you program GUIs; you have an event and you define a method to hook up to that event so that your running program can do some work in reaction to the user.

The process takes two steps: delegate and handler creation. In Figure , you can see that Code Completion is suggesting a method name for you. Just as a delegate provides an interface to a method that is a contract basically to describe how to communicate, you can also define interfaces to classes to communicate with them in a specified way, and these are intuitively named.

Implementing Interfaces Another language feature that gives you flexibility is interfaces. An interface can be useful if you want to have a group of classes that can be interchanged at any time, yet you need to write the same operations for each of these classes.

Essentially, you want to write the code that uses the class only one time, but still switch what the actual class is. The interface creates a contract that each of the interchangeable classes must adhere to. So, if the interface says that all classes that implement the interface have method A and property B, then every class that implements the interface must have method A and property B; the compiler enforces this like a contract that cannot be broken.

The following sections show you how to write an interface and then build a couple of classes that implement that interface. This definition of members is the contract of the interface. You are the one who must to write a class that contains the members of the interface, and you must write the code that provides an implementation of the interface members. A common point of confusion is that an interface does not have any executable code, but the classes that implement the interfaces do.

Name the Interface IAccount and click Add. By standard convention, you will always name any interface class you create with a name that starts with an uppercase letter I. The following sections show you how to build the classes that implement the IAccount interface; there, you should begin to see the benefit that an interface can bring.

Name the class Checking and click Add. Using the same procedure as Checking, add another class, but name it Saving. Listings and show the two new classes. NET: Intermediate Syntax In the C listing, following the class name by a colon and then the interface name specifies that the class will implement the interface.

In reality, the code in the methods would be different for Checking and Saving because they are different account types with different business rules. The next section gives you a couple of examples to help clarify the practical use of interfaces. Writing Code That Uses an Interface One of the best ways to understand the value of interfaces is to see a problem that interfaces solve. The particular example runs a payroll by obtaining instances of Checking and Saving classes and crediting each class, which is synonymous with employees being paid.

Starting with the bad example, Listing shows how this code works. You can see how the algorithm calls GetCheckingAccounts to retrieve an array of Checking objects. If you recall, an array is a list of elements of a specified type, that type being Checking in this case. The algorithm goes on to iterate through the Checking objects, invoking Credit on each to add to the account.

Some employees want their paychecks in Checking, but others might want their paychecks to go into Saving or some other account. Therefore, the algorithm calls GetSavingsAccounts to get a list of those accounts for employees who want their paychecks to go into their savings. The point to make here is that GetCheckingAccounts will only return Checking class instances and GetSavingsAccounts will only return Saving class instances. Although the Credit methods of Checking and Saving should have different implementations, the code calling Credit can be the same, eliminating duplication.

Listing shows how to take advantage of the fact that both Checking and Saving implement the same interface, IAccount. Looking inside of the GetAllAccounts method, you can see how an array is being built with both Checking and Saving objects. Since Checking and Saving implement IAccount, which you saw in Listings and , instances of Checking and Saving can be directly assigned into elements of an IAccount array.

The reason you can call Credit like this is that IAccount defines a contract for the Credit method. Your code that you wrote for Checking. Credit and Saving. Credit will execute as if your code called them directly as in Listing Credit in our example, works on both Checking and Saving objects. Now you can see that interfaces help you treat different types of objects as if they were the same type and helps you simplify the code you need to write when interacting with those objects, eliminating duplication.

Imagine what would happen if you were tasked with adding more bank account types to this algorithm without interfaces; you would need to go into the algorithm to write duplicate code for each account type. However, now you can create the new account types and derive them from IAccount; the new account types automatically work in the same algorithm. Because prefixing interfaces with I is an expected convention, the template highlights the identifier after I.

NET: Intermediate Syntax Applying Arrays and Generics Whatever code you write will typically need to group objects into a single collection of that object type. For this, you can use an array, which is a container that can have zero or many elements, each holding an instance of a particular type. There are also generic collection classes in the. NET Framework that are even more powerful than arrays. You declare a variable of the array type, instantiate the array to a specified size, and then use the array by indexing into its elements.

Listing shows an example that demonstrates the mechanics of creating and using an array. You must instantiate arrays, as is done by assigning new double[3] to stats, where 3 is the number of elements in the array.

C arrays are accessed via a 0-based index, meaning that stats has three elements with indexes 0, 1, and 2. The VB example declares stats as an array of type double. Notice that the rank of the array is 2, meaning that 2 is the highest index in the array. Since the array is 0-based, stats contains indexes 0, 1, and 2; three elements total. Assigning values to an array means that you use the name of the array and specify the index of the element you want to assign a value to.

For example, stats[0] stats 0 in VB is the first element of the stats array, and you can see from the listing how each element of the stats array is assigned the values 1. The for loop adds each element of the array to the sum variable. Finally, you can see how to read values from an array by examining the argument to the Console.

Using the element access syntax, you can see how to read a specific element from the stats array. An array is a fixed-size collection, and therefore somewhat limited in functionality. Not all collection classes in the.

NET Framework are generic collections; however, generic collections are now the preferred kind of collection to use in most cases. NET: Intermediate Syntax Coding Generics Generics are language features that allow you to write a piece of code that will work with multiple types efficiently. A generic class definition has a placeholder for the type you want it to represent, and you use this placeholder to declare the type you want to work with.

There is an entire library of generic collections in. NET as well as generic types across the entire. NET Framework Class library. Listing demonstrates how to declare a generic List.

The code specifies the type of the list as a Checking account and then proceeds to populate the generic list and perform operations on the Checking elements of the generic list. Remember to include a using directive imports for VB for the System.



0コメント

  • 1000 / 1000