The static keyword defines, that the class /property /method you declare as static does not require a previous instance of a object.In other hand static a method cannot use any instance method (or) instance property of the own object.
Also static defined things will be optimized by the compiler, for example that a static object is only
written once in the memory and everything accesses to the same object.
when we use static key word it means there is no need to create an instance of object ,static class including a static method called by class name.
Note: static class can have only static methods using System;
using System.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
namespacestatickeyword
{
class Program
{
public static void Number()
{
Console.WriteLine("Hi this static keywords");
Console.ReadLine();
}
static void Main(string[]args)
{
Program.Number();
}
}
}
OUTPUT:
Hi this is static keyword