相关疑难解决方法(0)

声明一个var而不初始化它......就在那里

有没有办法或技巧来做类似的事情:

var existingUsers; // This is not possible, but i need it to be global :)
try
{
    existingUsers = Repo.GetAll(); // This may crash, and needs to be in a try
}
catch (Exception)
{
    throw new Exception("some error, don't bother");
}

if (existingUsers.Count > 0)
    {
        //some code
    }
Run Code Online (Sandbox Code Playgroud)

或者也许是我正在尝试做的替代方案?

.net c# var

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

标签 统计

.net ×1

c# ×1

var ×1