3

这是我目前遇到问题的代码:

        try

        {
            int realopid = Convert.ToInt16(operatorid);
        }
        catch (OverflowException)
        {
            //Create Message Box
            MessageBox.Show("Please Scan Valid Operator ID", "Operator ID");
            operatorid = Microsoft.VisualBasic.Interaction.InputBox("Scan Operator ID", "Operator ID");
        }

            string res = lookupName( realopid );
4

1 回答 1

6

您正在定义realopidtry 块的内部。它只在那里可见。你应该在外面定义它。

int realopid = 0;
try
{
   realopid = Convert.ToInt16(operatorid);
}
catch (OverflowException)
{
    //Create Message Box
    MessageBox.Show("Please Scan Valid Operator ID", "Operator ID");
    operatorid = Microsoft.VisualBasic.Interaction.InputBox("Scan Operator ID", "Operator ID");
 }
string res = lookupName(realopid);
于 2012-12-11T12:21:12.507 回答