Join Anton Delsink for an in-depth discussion in this video Processing text with StreamReader, part of Object Oriented Programming with C#.
- [Instructor] So now that we've upgraded…our reading of the file data from a FileStream…to a StreamReader and used the benefit…of the StreamReader implementing IDisposable,…let's follow the typical path and of reading…all of the lines of text from this file.…I'll copy the whole method,…rename it to number 15,…and so now, this first line we're definitely…not interested in, it's just a headings…but we want to read through all the lines of data,…one after another until we run out.…
Now ReadLine, if you read the documentation,…will tell you that it will give you a string…as long as there is data.…But when it reaches the end of the file,…it will give you null.…So if line one is equal to null,…then there's nothing else to do and we're done.…So we can say the opposite, while the line is not null,…we have data, so let's keep reading.…While string line is going to start its life as null…and then we will assign to line StreamReader.ReadLine…and if that is not null,…so watch the pattern here,…line being assigned the value that's returned from ReadLine.…
- 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.