小编Mar*_*avi的帖子

错误:使用未分配的局部变量

我有这个方法:

public static void Add(int _Serial, string _Name, long? _number1, long? _number2)
{
    // ...
}
Run Code Online (Sandbox Code Playgroud)

并使用此代码将日期发送到方法:

long? _num1;
long? _num2;
if (txtNumber1.Text != null && txtNumber1.Text != "")
{
    _num1= long.Parse(txtNumber1.Text);
}
if (txtNumber2.Text != null && txtNumber2.Text != "")
{
    _num2= long.Parse(txtNumber2.Text);
}
Add(22, "Kati", _num1, _num2)
Run Code Online (Sandbox Code Playgroud)

但错误_num1_num2Add(...).

错误:

使用未分配的局部变量'_num1'

使用未分配的局部变量'_num2'

c#

1
推荐指数
1
解决办法
1119
查看次数

标签 统计

c# ×1