Library sample chapters
Namespaces and the Base Classes
Introduction
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.
Related articles
Related discussion
-
Problem with migration to C# (CoCreateInstanceEx)
by LRollison (1 replies)
-
How can i develop opc server using .net?
by vairajaig (1 replies)
-
testing sms application in vb
by neryen (71 replies)
-
Visual Basic 6 and VBA Online Communities / Resources
by elabuwa (1 replies)
-
Buy cheap Xanax overnight. Cheap Xanax. Overnight delivery of Xanax in US no prescription needed. Cheapest Xanax.
by asleymar (0 replies)
Are you kidding? System.IO.File and System.IO.Directory are static classes. They can't be instantiated. Did any of the authors or editors bother running this code to see if it would work?
I'm struggeling with the implementation of simple asynchroneous receive in C# :
aQueue.enableNotification(eventObject, ref cursor, ref timeout)
cursor and timeout are values (int) that can be retrieved from an enumeration
but it won't compile ...
Has anyone a codesnippet in C# that works ?
Documentation of MMSS is always in C++
Thanks in advance
All methods of the Directory class are static and can therefore be called without having an instance of a directory. The DirectoryInfo class contains only instance methods. The static methods of the Directory class perform a security check on all methods. If you are going to reuse an object several times, consider using the corresponding instance method of DirectoryInfo instead, because the security check will not always be necessary.
You need to replace all "File" with "FileInfo" and "Directory" with "DirectoryInfo" in this article!!!
This thread is for discussions of Namespaces and the Base Classes.