adplus-dvertising
frame-decoration

Question

Which of the following statements is correct about the C#.NET code snippet given below?

switch (id)
{
    case 6: 
        grp = "Grp B"; 
        break;
    
    case 13:
        grp = "Grp D";
        break;
    
    case 1:
        grp = "Grp A";
        break;
    
    case ls > 20:
        grp = "Grp E";
        break ;
    
    case Else:
        grp = "Grp F";
        break;
}

a.

Compiler will report an error in case ls > 20 as well as in case Else.

b.

There is no error in this switch case statement.

c.

Compiler will report an error only in case Else.

d.

Compiler will report an error as there is no default case.

Posted under C# programming

Answer: (a).Compiler will report an error in case ls > 20 as well as in case Else.

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following statements is correct about the C#.NET code snippet given below?