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

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.

Updated on: 22-Jun-2020

10K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started