Created
July 30, 2017 13:55
-
-
Save pawlos/781a1d39875eec87f624f2c575dc15f6 to your computer and use it in GitHub Desktop.
Użycie goto w try-finally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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