Dan*_*nny 15 c# return try-catch
我有以下代码:
public DataTable GetAllActiveUsers()
{
DataTable dataTable = new DataTable();
try
{
connection.Open();
SqlCommand getAllActiveUsersCommand = new SqlCommand(getAllUsers, connection);
SqlDataAdapter dataAdapter = new SqlDataAdapter(getAllActiveUsersCommand);
dataAdapter.Fill(dataTable);
return dataTable;
}
catch(Exception e)
{
Console.WriteLine(e);
return null;
}
finally
{
connection.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
这基本上是我的数据库中的活跃用户.但有人可以向我解释,Finally如果成功运行try块并返回DataTable,是否会执行Block ?
谢谢