gpt4 book ai didi

c# - 当前上下文错误中不存在名称 'string' c#

转载 作者:行者123 更新时间:2023-11-30 14:34:35 29 4
gpt4 key购买 nike

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

        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 );

最佳答案

您正在 try block 中定义 realopid。它只在那里可见。你应该在外面定义它。

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);

关于c# - 当前上下文错误中不存在名称 'string' c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13820306/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com