Basic namespaces: System

by Johannes Roith (johannes@jroith.de)

Contents

All these Classes need to be described. Who wants to help? Helping is really easy and a straight forward task. It's enough if you pick only *one* class. Contact me at johannes@jroith.de.

I. System.Object

[TODO:GetType(), ToString(), GetHashCode(), Equals(), ReferenceEquals();MemberWiseClone();]

System.Console

Provides access to input and output.

Console.Write() : Writes output to the console.
Console.WriteLine() : Adds \n at the end of the line.

Both are overloaded serval time, so you can pass them Boolean, Int32, Char, Double, String, ...

Console.Read() : Read a single char.
Console.WriteLine() : Reads complete line.

// getname.cs

using System;

class consoletest {

        public static void Main(){

                string name;

                Console.Write("Please enter your name: ");
                name = Console.ReadLine();
                Console.WriteLine("Hello, " + name + "!");

        }

}

System.String

[TODO]

System.Uri

[TODO]

System.UriBuilder

[TODO]

System.Convert

[TODO]

System.GC

[TODO]

System.BitConverter

[TODO]

System.Version

This class is overloaded and can either generate a version number string (x.x.x.x) from 4 integers, or split a version string in it's four numbers.

Each number is then accessible as obj.Major, obj.Minor, obj.Revision, obj.Build.

// guidtest.cs
// Generates a version form 4 integers, Splits the numbers again from the string.

using System;

class versiontest {

        public static void Main(){

                Version v = New Version(1, 3, 12, 40);

                // v.ToString() is now  "1.3.12.40"
                Version v2 = New Version(v.ToString());

                Console.WriteLine("Major:"    + v2.Major);
                Console.WriteLine("Minor:"    + v2.Minor);
                Console.WriteLine("Revision:" + v2.Revision);
                Console.WriteLine("Build:"    + v2.Build);              

        }

}

System.Guid

This class can generate a "Global Unique Indetifier", that is unique across time and location.

Important is, that the method NewGuid must be called, to generate an unique number.

// guidtest.cs

using System;

class guidtest {

        public static void Main(){

                string name;
                Guid myguid = New Guide();
                myguide = myguide.NewGuid();

                Console.WriteLine(myguide.ToString());

        }

}

System.Math

Offers 2 mathematical constants: e and pi

Offers many mathematical functions:

[TODO: Explain function and using]

[TODO: Write a big example, where they all can be used]

System.Environment

This class contains only static methods, that provide information about the OperatingSystem.

There is nothing to explain, instead of that here is a good commented example, printing all properties.

[TODO: Write Example]

// enviroment.cs

using System;

class r1 {

        public static void Main(){

                Console.WriteLine("Computer name: " + System.Enviroment.MachineName);

                // continue...
        }

}