What is the difference between public, static and void keywords in C#?

CsharpProgrammingServer Side Programming

All these keywords are part of the main method of any C# program.

The Main method, which is the entry point for all C# programs states that what a class does when it executed.

using System;
class Demo {
   static void Main(string[] args) {
      Console.WriteLine("My first program in C#!");
   }
}
  • public − This is the access specifier that states that the method can be accesses publically.

  • static −  Here, the object is not required to access static members.

  • void − This states that the method doesn’t return any value.

  • main − is As stated above, it s the entry point of a C# program i.e. this method is the method that executes first.

raja
Published on 21-Aug-2018 07:57:23
Advertisements