C# Program Structure :

Basic Program in C# Language :

  1. /* Author: techbaz.org
  2. Date: 2018-11-17
  3. Description: "Hello World" on the screen */
  4. using System;
  5. namespace DemoProgramming
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Console.WriteLine(" \n Hello World");
  12. Console.ReadKey();
  13. }
  14. }
  15. }

Output :

C Sharp Language Hello World program

Note : C# is case sensitive and you can use '\n' for create a new line.


using System;

the using keyword is used to include the System namespace in the program. A program generally has multiple using statements.

namespace

A namespace is a collection of classes. The DemoProgramming namespace contains the class Program.

class

the class Program contains the data and method definitions that your program uses. Classes generally contain multiple methods. Methods define the behavior of the class. However, the Program class has only one method Main.

Main

Main is the entry point for all C# programs. The Main method states what the class does when executed.

/* comments */

/*...*/ is ignored by the compiler and it is put to add comments in the program.

WriteLine

WriteLine is a method of the Console class defined in the System namespace. This statement causes the message "Hello World" to be displayed on the screen.

ReadKey

Console.ReadKey(); This makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.


Next Update

Loading...

Currently we improved our website User Interface and other contents. Our next update is adding video tutorials on this site so, We create a new YouTube channel, our YouTube channel name is CodeX.

We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels