Skip to content

Instantly share code, notes, and snippets.

@pawlos
Created July 30, 2017 13:55
Show Gist options
  • Save pawlos/781a1d39875eec87f624f2c575dc15f6 to your computer and use it in GitHub Desktop.
Save pawlos/781a1d39875eec87f624f2c575dc15f6 to your computer and use it in GitHub Desktop.
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