.NET Framework Classes


Perhaps one of the biggest benefits of writing managed code, at least from a developer’s point of view, is that you get to use the .NET base class library.

The .NET base classes are a massive collection of managed code classes that allow you to do almost any of the tasks that were previously available through the Windows API. These classes follow the same object model IL uses, based on single inheritance. This means that you can either instantiate objects of whichever .NET base class is appropriate or you can derive your own classes from them.

The great thing about the .NET base classes is that they have been designed to be very intuitive and easy to use. For example, to start a thread, you call the Start() method of the Thread class. To disable a TextBox, you set the Enabled property of a TextBox object to false. This approach - while familiar to Visual Basic and Java developers, whose respective libraries are just as easy to use - will be a welcome relief to C++ developers, who for years have had to cope with such API functions as GetDIBits(), RegisterWndClassEx(), and IsEqualIID(), as well as a whole plethora of functions that required Windows handles to be passed around.

On the other hand, C++ developers always had easy access to the entire Windows API, whereas Visual Basic 6 and Java developers were more restricted in terms of the basic operating system functionality that they have access to from their respective languages. What is new about the .NET base classes is that they combine the ease of use that was typical of the Visual Basic and Java libraries with the relatively comprehensive coverage of the Windows API functions. Many features of Windows still are not available through the base classes, and for those you will need to call into the API functions, but in general, these are now confined to the more exotic features. For everyday use, you will probably find the base classes adequate. And if you do need to call into an API function, .NET offers a so-called platform-invoke that ensures data types are correctly converted, so the task is no harder than calling the function directly from C++ code would have been - regardless of whether you are coding in C#, C++, or Visual Basic 2005.

Tip 

WinCV, a Windows-based utility, can be used to browse the classes, structs, interfaces, and enums in the base class library. WinCV is discussed in Chapter 14, “Visual Studio 2005.”

Although Chapter 3 is nominally dedicated to the subject of base classes, in reality, once we have completed our coverage of the syntax of the C# language, most of the rest of this book shows you how to use various classes within the .NET base class library for both .NET 2.0 and the new .NET Framework 3.0. That is how comprehensive base classes are. As a rough guide, the areas covered by the .NET 2.0 and 3.0 base classes include:

  • Core features provided by IL (including the primitive data types in the CTS discussed in Chapter 3, “Objects and Types”)

  • Windows GUI support and controls (see Chapter 28, “Windows Forms,” and 31, “Windows Presentation Foundation”)

  • Web Forms (ASP.NET, discussed in Chapters 32, “ASP.NET Pages” and 33, “ASP.NET Development”)

  • Data access (ADO.NET; see Chapters 25, “Data Access with .NET,” 27, “.NET Programming with SQL Server 2005,” and 26, “Manipulating XML”)

  • Directory access (see Chapter 42, “Directory Services”)

  • File system and registry access (see Chapter 24, “Manipulating Files and the Registry”)

  • Networking and Web browsing (see Chapter 35, “Accessing the Internet”)

  • .NET attributes and reflection (see Chapter 12, “Reflection”)

  • Access to aspects of the Windows OS (environment variables and so on; see Chapter 19, “.NET Security”)

  • COM interoperability (see Chapters 38, “Enterprise Services” and 23, “COM Interoperability”)

Incidentally, according to Microsoft sources, a large proportion of the .NET base classes have actually been written in C#!




Professional C# 2005 with .NET 3.0
Professional C# 2005 with .NET 3.0
ISBN: 470124725
EAN: N/A
Year: 2007
Pages: 427

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