CHAPTER 3 C# LANGUAGE FUNDAMENTALS (Web hosting billing) 69 //
CHAPTER 3 C# LANGUAGE FUNDAMENTALS 69 // List the drives on this machine. string[] drives = Environment.GetLogicalDrives(); for(int i = 0; i < drives.Length; i++) Console.WriteLine("Drive {0} : {1} ", i, drives[i]); // Which version of the .NET platform is running this app? Console.WriteLine("Executing version of .NET: {0} ", Environment.Version); ... } Possible output can be seen in Figure 3-3. The System.Environment type defines members other than those presented in the previous example. Table 3-1 documents some additional properties of interest; however, be sure to check out the .NET Framework 2.0 SDK documentation for full details. Table 3-1. Select Properties of System.Environment Property Meaning in Life MachineName Gets the name of the current machine NewLine Gets the newline symbol for the current environment ProcessorCount Returns the number of processors on the current machine SystemDirectory Returns the full path to the system directory UserName Returns the name of the entity that started this application Defining Classes and Creating Objects Now that you have the role of Main() under your belt, let s move on to the topic of object construction. All object-oriented (OO) languages make a clear distinction between classes and objects. A class is a definition (or, if you will, a blueprint) for a user-defined type (UDT). An object is simply a term describing a given instance of a particular class in memory. In C#, the new keyword is the de facto way to create an object. Unlike other OO languages (such as C++), it is not possible to allocate a class type on the stack; therefore, if you attempt to use a class variable that has not been new-ed, you are issued a compile-time error. Thus the following C# code is illegal: Figure 3-3. Various environment variables at work
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.