Guaranteed code execution in C#
Forums:
void ThrowIfTrue(bool param) {
try {
if (param)
throw new Exception("test exception");
}
catch{
Console.WriteLine("catch");
}
finally {
Console.WriteLine("finally");
}
}
ThrowIfTrue(true);
//printed: "catch" and "finally"
ThrowIfTrue(false);
//printed only "finally"
- Log in to post comments