This is a sample chapter from C# Programming with the Public Beta
A significant part of the power of the .NET framework comes from the base classes supplied by Microsoft as part of the .NET framework. These classes are all callable from C# and provide the kind of basic functionality that is needed by many applications to perform, amongst other things, basic system, Windows, and file handling tasks. To a large extent the .NET base classes can be seen as replacing the previous Win32 API and a large number of MS-supplied COM components. The base classes are simpler to use, and you can easily derive from them to provide your own specialist classes. You can also use the base classes from any .NET-aware language (calling Win32 API functions from VB was possible but not easy). The types of purposes you can use the base classes to do include:
- String handling
- Arrays, lists, maps etc.
- Accessing files and the file system
- Accessing the registry
- Security
- Windowing
- Windows messages
- Connecting to other computers and to the Internet
- Drawing
- Directory Access
- Database Access
You can see from the above list that besides giving access to basic Windows
operations, the base classes define many useful data types, including strings
and collections of data.
The base classes are not, of course, only available to C# programs - they can
equally well be accessed from VB, C++ or any other .NET-compliant or (by use
of some wrapper objects) COM-aware language, but we will concentrate on C# here.
The aim of this chapter is to give you an overview of the kinds of things you
can do using the base classes and how to perform certain common operations. Clearly
the scope of the base classes is so vast that we cannot give any kind of comprehensive
guide in one chapter - instead we are going to pick on a few common programming
tasks and present sample code to demonstrate how you can easily execute those
tasks. However we will also show you how you can use the WinCV tool which is
supplied with the .NET SDK to explore the base classes for yourself.
The tasks we're going to cover in this chapter include:
- Manipulating dates and times
- Navigating the file system
- Reading and writing to files
- Copying, Moving and Deleting files
- Connecting to the Internet
- Accessing the registry
- Mathematical functions
Note that we are not covering windowing or data access in this chapter. These
areas are important enough to warrant chapters in their own right and are respectively
covered in Chapters 8 and 9.
Before we do that though, we need to switch topics for a while and understand
how namespaces work in C#, since you need to be able to use and reference namespaces
in order to be able to access the base classes.
Comments