Static class and its inner class : static Class « Class « C# / CSharp Tutorial






using System;

public static class StaticClass
{
    public static void DoWork() {
        ++CallCount;
        Console.WriteLine( "StaticClass.DoWork()" );
    }

    public class NestedClass {
        public NestedClass() {
            Console.WriteLine( "NestedClass.NestedClass()" );
        }
    }

    public static long CallCount = 0;
}

public static class MainClass
{
    static void Main() {
        StaticClass.DoWork();

        StaticClass.NestedClass nested = new StaticClass.NestedClass();

        Console.WriteLine( "CallCount = {0}", StaticClass.CallCount );
    }
}
StaticClass.DoWork()
NestedClass.NestedClass()
CallCount = 1








7.42.static Class
7.42.1.Demonstrate a static class.
7.42.2.Static class and its inner class
7.42.3.Static inner class constructor