C# Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - General Questions (Q.No. 7)
7.
What will be the output of the C#.NET code snippet given below?
char ch = Convert.ToChar ('a' | 'b' | 'c'); 
switch (ch)
{
    case 'A': 
    case 'a':
    Console.WriteLine ("case A | case a");
    break;
    
    case 'B': 
    case 'b':
    Console.WriteLine ("case B | case b");
    break;
    
    case 'C':
    case 'c':
    case 'D':
    case 'd':
    Console.WriteLine ("case D | case d");
    break;
}
case A | case a
case B | case b
case D | case d
Compile Error
No output
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
13 comments Page 2 of 2.

Mayank Kumar said:   8 years ago
Pleas e solve this Query .
What will be output. I can not understand logic.

char ch = Convert.ToChar('a' | 'B' | 'C'|'D' );

Sridhar said:   7 years ago
How? tell me.

Karthickkumar A said:   2 years ago
I do not understand how the variable ch takes the value 'c'. Can somebody explain this, please?

Thanks.


Post your comments here:

Your comments will be displayed after verification.