C# Program to print Hello World
Program
using System;
namespace Application
{
public class HelloWorld
{
public static void Main(String[] args)
{
Console.WriteLine("Hello World!!!");
Console.WriteLine("Welcome to oodlescoop");
}
}
}
This C# program prints "Hello World!!!" and "Welcome to oodlescoop" to the console.
-
using System;
- Imports the
System
namespace, which provides core functionalities, including console input/output.
- Imports the
-
namespace Application
- Defines a namespace called
Application
to group related classes.
- Defines a namespace called
-
public class HelloWorld
- Declares a class named
HelloWorld
. In C#, all code must be inside a class.
- Declares a class named
-
public static void Main(String[] args)
- The
Main
method is the entry point of a C# program. static
means it belongs to the class and does not require an instance.void
means the method does not return any value.String[] args
allows command-line arguments to be passed.
- The
-
Console.WriteLine("Hello World!!!");
- Prints
"Hello World!!!"
to the console. Console.WriteLine()
is used for output with a newline at the end.
- Prints
-
Console.WriteLine("Welcome to oodlescoop");
- Prints
"Welcome to oodlescoop"
to the console on a new line.
- Prints
Output
$ mcs HelloWorld.cs
$ mono HelloWorld.exe
Hello World!!!
Welcome to oodlescoop