Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Użycie goto w try-finally
FileStream f = null;
try
{
f = File.OpenRead("file.txt");
if (f.CanWrite == false)
{
Console.WriteLine("Przed goto");
goto goto_out;
}
}
finally
{
Console.WriteLine("Finally? Yay!");
if (f != null)
f.Close();
}
goto_out:
Console.WriteLine("Po try-catch");
//Output:
//Przed goto
//Finally? Yay!
//Po try-catch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment