Skip to content

Instantly share code, notes, and snippets.

@pawlos
Created July 30, 2017 13:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
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