Question: I have a c# console app that I am able to catch invalid integer inputs but not sure how to implement catching string inputs(if user

I have a c# console app that I am able to catch invalid integer inputs but not sure how to implement catching string inputs(if user inputs test instead of 1, 2 or 3)

do

{

Console.WriteLine("1. choice 1");

Console.WriteLine("2. choice 2");

Console.WriteLine("3. choice 3");

int selection = Convert.ToInt32(Console.ReadLine());

switch(selection)

{

case 1:

//code here

break;

case 2:

//code

break;

case 3:

//code

break;

default:

Console.WriteLine("Invalid number input");

break;

}

}while(true)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!