Home »
MCQs »
C# MCQs
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));
}
}
}
- 10.30
- 10.25
- 10
- 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".