What will be the output of the following C# code? | Question 5

36. 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},{0}", a, b);
    }
  }
}
  1. 10,10
  2. 10,20
  3. 20,20
  4. Error

Answer: A) 10,10

Explanation:

In the above code, there are two variables a and b, but while printing the values of a and b, we are using the same placeholder {0}, that will print the value of the first variable. Thus, the output is 10,10.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.