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

30. What will be the output of the following C# code?

using System;

namespace MyApplication {
  class Program {
    static void Main(string[] args) {
      double x = 10.25;
      Console.Write(Convert.ToInt32(x));
    }
  }
}
  1. 10.30
  2. 10.25
  3. 10
  4. Error

Answer: C) 10

Explanation:

In the above C# code, we are using Convert.ToInt32() method which converts double to int. Thus, the output will be "10".

Comments and Discussions!

Load comments ↻






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