Created
August 20, 2014 16:59
-
-
Save davkean/986d8ac6cd65f585e442 to your computer and use it in GitHub Desktop.
Leaking enumerable
This file contains hidden or 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
DirectoryInfo info = new DirectoryInfo(@"C:\Temp"); | |
IEnumerable<FileInfo> files = info.EnumerateFiles("*.txt") | |
.Where(f => f.CreationTimeUtc > lastWeek); | |
foreach (FileInfo file in files) | |
{ | |
} // With your proposal, where does Dispose get called on the strong-typed enumerable returend by EnumerateFiles? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment