有没有办法或技巧来做类似的事情:
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)
或者也许是我正在尝试做的替代方案?