Home »
.Net »
C# Programs
C# Hello World - First C# Program
C# | "Hello World" Program: In this tutorial, we will learn how to write a simple C# program to "Hello World" on the console, also learn the basic syntax and requirements that are required to write a C# program.
By IncludeHelp Last updated : April 15, 2023
"Hello world" Program in C#
To print the message/text or any value – we use two functions:
- Console.Write ();
This function displays text, values on the output device and does not insert a new line after the message.
- Console.WriteLine();
This function displays text, values on the output device and inserts a new line after the message.
So, in this program – we are printing some of the messages with and without inserting new line after the message. And also explaining how we can print new line using escape sequence \n between the messages.
C# code to print "Hello World"
/*c# basic program to print messages*/
using System;
class HelloWorld {
static void Main() {
//print text without inserting new line
//after the message
Console.Write("Hello World,");
Console.Write("How are you?");
//print new line
Console.WriteLine();
//print text with new line after the message
Console.WriteLine("Hello World");
Console.WriteLine("How are you?");
//print new line using escape sequence
//just like C language
Console.WriteLine("Hello World\nHow are you?");
}
}
Output
Hello World,How are you?
Hello World
How are you?
Hello World
How are you?
C# Basic Programs »