Static Keyword

Posted by charanmode64-25354 under C# category on | Points: 40 | Views : 2242
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;
class Program
public static void Number()
Console.WriteLine("Hi this static keywords");
static void Main(string[]args)



Hi this is static keyword

Comments or Responses

Login to post response