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//from   ww  w .j  av  a  2s  . c  o  m
{
    public static void Main(string[] args)
    {

        Console.WriteLine(MyClass.i);

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

Result

Related Topics