假设我有以下代码:
static void Fjuk(out string str)
{
str = "fjuk!";
throw new Exception();
}
static void Main(string[] args)
{
string s = null;
try
{
Fjuk(out s);
}
catch (Exception)
{
Console.WriteLine(s ?? "");
}
}
当我测试它时,在catch
块中使用的s
已被初始化为"fjuk!"。
这是规范保证的还是与实现有关?(我已经搜索了C# 3规范,但自己找不到)