Home
Aptitude
Categories


Home » C# programs » C# basic programs

C# | Print messages/text (program to print Hello world)



C# basic program to print hello world: Here, we are writing a basic program in C# that will print the messages/text on the output.
Submitted by IncludeHelp, on December 04, 2018

To print the message/text or any value – we use two functions:

  1. Console.Write ();
    This function displays text, values on the output device and does not insert a new line after the message.
  2. 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.

Program:

/*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?





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.