private void SomeFunction() { using (StreamReader sr = new StreamReader("C:\\File.txt")) { if (someCondition) { return; } } }
sr.Dispose()
finally
using
private void SomeFunction() { StreamReader sr = new StreamReader("C:\\File.txt"); try { if (someCondition) return; } finally { sr.Dispose(); // same happens "on the closing '}' of using statement" } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)