Join Anton Delsink for an in-depth discussion in this video Opening FileStream with StreamReader, part of Object Oriented Programming with C#.
- [Instructor] Now that we've seen the foreach keyword's…implementation using the INumerable interface…and we've seen the Dispose method being called…thanks to the using keyword and the IDisposable interface,…let's combine the two for when we want to read through…a lengthy file, iterate through all the lines in the file…and make sure that we clean up after we've used the file…means closing the file or calling Dispose…on the FileStream object.…And so I'll copy and paste the method we had before,…copy FileStream test 13, paste,…rename it to 14,…let's delete the remaining comments.…
So you should be left with Test_014_FileStream as a method…that has just a handful of lines of code.…So we said using var fs, calls new FileStream,…the using statement means the last closing bracket…here on line 143 will be expanded to be a finally block…and if fs is not null,…the Dispose method will be called on it.…So that's a great start but FileStream…and this ReadByte or reading a block of binary bytes…on a per block basis is way too much work,…
- Abstract classes
- Processing text with StreamReader
- IEnumerable and yield return
- Windows Forms controls
- Windows Forms with and without the designer
- Adding, organizing, and testing forms
- Creating classes
Skill Level Intermediate
What you should know1m 10s
1. Theory vs. Practice
2. Examples from .NET
3. Examples from Windows UI
4. Examples from Board Games
5. Examples from the Web
Next steps1m 13s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.