Home »
MCQs »
C# MCQs
What will be the output of the following C# code? | Question 6
37. What will be the output of the following C# code?
using System;
namespace MyApplication {
class Program {
static void Main(string[] args) {
int a = 10, b = 20;
Console.WriteLine("{0}+{1}", a, b);
}
}
}
- 20
- 30
- 10+20
- 10+10
Answer: C) 10+20
Explanation:
In the statement, Console.WriteLine("{0}+{1}", a, b); - {0} is the placeholder for variable a and {1} is the placeholder for variable b, {0}+{1} will not perform any operation, values of a and b will be printed at the place of {0} and {1}. Thus, the output will be 10+20.