The Hello World! program is the most basic and first program when you dive into a new programming language. This simply prints the Hello World! on the output screen. In C#, a basic program consists of the following:
- A Namespace Declaration
- Class Declaration & Definition
- Class Members(like variables, methods etc.)
- Main Method
- Statements or Expressions
Example:
CSharp
// C# program to print Hello World!
using System;
// namespace declaration
namespace HelloWorldApp {
// Class declaration
class Geeks {
// Main Method
static void Main(string[] args) {
// statement
// printing Hello World!
Console.WriteLine("Hello World!");
// To prevents the screen from
// running and closing quickly
Console.ReadKey();
}
}
}