For the given set of C# code, is conversion possible? [code] static void Main(string[] args) { int a = 76; char b; b =

Huyền Thu

New member
For the given set of C# code, is conversion possible?
Code:
 static void Main(string[] args)
 {
     int a = 76;
     char b;
     b = (char)a;
     Console.WriteLine(b);
     Console.ReadLine();
 }
A. Compiler will generate runtime error
B. Conversion is explicit type
C. Compiler will urge for conversion from ‘integer’ to ‘character’ data type
D. None of the mentioned
 
Answer: b
Explanation: Since, given conversion is of explicit type as one data type is in integer and other is in ‘char’. Compiler is needed to make a clear distinction between both type of data types and hence, explicitly one need to specify data type as compiler is unable to make automatic conversion.
Output :
Code:
 L.
 

Tìm kiếm

Back
Top