CSharp - Type Creation Static Classes

Introduction

A class can be marked as static.

static class must have only static members and cannot be subclassed.

System.Console and System.Math classes are are static classes.

Demo

using System;
class MainClass/* w w w  . j  a  va 2 s  . c  o m*/
{
    public static void Main(string[] args)
    {

        Console.WriteLine(MyClass.i);

    }
}
static class MyClass
{
    public static int i = 9;
}

Result

Related Topics