Printing program output / data on Console in C#

(Last Updated On: January 10, 2019)

Console output in C# – Learn how to print program outputs in C# on console screen using Console.WriteLine method. You will learn how to print Strings, int and double variables etc on console.

Here is a simple C# program that prints output as “I love C# Programming”.

Output:
I Love C# Programming

Notice that string “I Love C# programming” is in double quote.

 

Printing multiple Strings on Console in C#

Here is another example of printing multiple strings in C# program.

Output:
My name is Peter
I am learning C#
I like Coffee

 

Printing variables in C# on Console

You can print value of int, double and String variables in C# program on console screen.

C# code:

Output:
I Like Coffee
2
99.0

 

Printing multiple values in one line on Console

You can print multiple types of data by appending them using + symbol in Console.WriteLine method in one line.

C# code example:

In below program an int variable and a string variable are appended in Console.WriteLine method using + symbol.

Output:
100 Coffee!!!

 

WARNING:

Beginners make mistake of using common symbol (,) instead of (+ )symbol . For example, Console.WriteLine(count,str);

One more example below on console output in C#

that is appending a hard code string “value = “ and an int value of variable num.

Output:
value= 100

Output:
value= 100

 

NOTE: Having space before or after + symbol, does not affect the output. For example, in above program, both statements given below produces same output.

Console.WriteLine(“value = “+ num)
Console.WriteLine(“value = ” + num);

 

Written By Shilpa Jaroli & Reviewed by Rakesh Singh