MCQs > IT & Programming > C# > What is the issue with the following function? public string GetName(int iValue) { string sValue = '0'; switch (iValue) { case 1: sValue = iValue.ToString(); case 2: sValue = iValue.ToString(); break; default: sValue = '-1'; break; } return sValue; }

C# MCQs

What is the issue with the following function?

public string GetName(int iValue)

{

    string sValue = "0";

    switch (iValue)

    {

        case 1:

            sValue = iValue.ToString();

        case 2:

            sValue = iValue.ToString();

            break;

        default:

            sValue = "-1";

            break;

    }

    return sValue;

}

Answer

Correct Answer: The code will not compile as there is no break statement in case 1.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it