To display single variable value in C#, you just need to use Console.WriteLine()
Let us see an example. Here, we have displayed the value of a single variable “a” in a line −
Example
using System;
using System.Linq;
class Program {
static void Main() {
int a = 10;
Console.WriteLine("Value: "+a);
}
}To display multiple variables value in C#, you need to use the comma operator in Console.WriteLine().
Let us see an example. Here, we have displayed the value of multiple variables “a” and “b” in a line −
Example
using System;
using System.Linq;
class Program {
static void Main() {
int a = 10;
int b = 15;
Console.WriteLine("Values: {0} {1} ",a,b);
}
}Above, the {0} is replaced by the value of variable a, whereas {1} is replaced by the value of variable b.