C# First Application

Let’s see the first simple program in C# which prints Hello word on the console.


Description of the first Program:

  1. class: it’s a keyword which is used to define class. in C#, we have to define class first before main method .
  2. static: It is a keyword which is used to declare the class variable. We don’t need to create object to access static variable .
  3. void: void is a return type of the main method .
  4. Main: In C#, we have to write Main instead of main .
  5. string[] args: It is string array which is used to store the command line arguments. Writing this is optional.
  6. Console.WriteLine(“Hello World”): System is the name space. We are writing fully qualified name here. We could have used System name space before. WriteLine is the method used for writing on the console .

C# Example: using System namespace

In the first example, if we could have used System namespace then we didn’t need to write fully qualified name to access its method .


C# Example : using public modifier


C# Example: using Namespace

We can organize our classes and code in a namespace. It is a better way to organize your classes.


Leave a Comment