2.13 Creating and Using Class Libraries

 <  Day Day Up  >  

You want to create a class and package it within a dynamic-link library rather than an executable file.


Technique

Create a new project by choosing New, Project from the main menu. Select Visual C# Projects from the list of project types. In the list of project templates, select the Class Library template.

To use an object within a class library, right-click on the client project name in Solution Explorer and select Add Reference. Select the .NET tab in the Add Reference dialog, shown in Figure 2.4, and then click the Browse button. Locate the class library that contains the classes you want to use.

Figure 2.4. To use a type defined in a class library, you must create a reference to it in your project.

graphics/02fig04.jpg

Comments

Class libraries allow you to put into a single shared package code that many different modules can use. By itself, a class library cannot run because it is not an executable. It is simply a container of resources and types that can be referenced. The .NET Framework contains several class libraries known collectively as the FCL, or Framework Class Libraries. Up to this point in the book, you have been using types defined within the System library, which is contained within the System.dll assembly. The .NET Framework has many more class libraries, which you will no doubt be familiar with by the end of this book.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net