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//www.j  a  v  a2  s.  c om
{
    public static void Main(string[] args)
    {

        Console.WriteLine(MyClass.i);

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

Result

Related Topics