我有这个代码:
else if (number == 5)
{
Console.Write("Student's index: ");
int index1 = int.Parse(Console.ReadLine());
try
{
customDataList.FindStudent(index1); //displays the element that has the specified index
}
catch (ArgumentOutOfRangeException)
{
Console.WriteLine("Please choose an index from 0 to 9!");
}
}
当用户未输入任何字符或输入非整数字符时,我需要使用 try-catch 处理错误。怎么可能呢?
HUWWW
翻阅古今
相关分类