The Program in C# Program to print Hello and your name in a separate line are given below:
using System;
namespace HelloName
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello Everybody, How is it going ,huh!");
Console.WriteLine("To Codeauri Family");
}
}
}
Output:
Hello Everybody, How is it going ,huh!
To Codeauri Family
Pro-Tips💡
Here’s a step-by-step explanation of the above code:
using System;
: This line imports theSystem
namespace, which contains many useful classes, including theConsole
class that we will use to interact with the console.namespace HelloName
: This line declares a new namespace calledHelloName
. A namespace is used to organize code and prevent naming collisions with other code in different namespaces.class Program
: This line declares a new class calledProgram
. TheMain
method will be defined inside this class.static void Main(string[] args)
: This line declares theMain
method, which is the entry point for the program. TheMain
method isstatic
, meaning it can be called without creating an instance of the class. Thevoid
return type means that theMain
method doesn’t return a value. Thestring[] args
parameter is an array of strings that can be passed as command-line arguments to the program.Console.WriteLine("Hello");
: This line writes the string “Hello” to the console using theWriteLine
method of theConsole
class. TheWriteLine
method writes the text to the console and appends a newline character to the end.Console.WriteLine("Your name");
: This line writes the string “Your name” to the console in a separate line, just like in step 5.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.