C
C#14mo ago
Spekulant

❔ ✅ SreamReader vs. TextReader

Given i want to program a reader that is efficient so i will read by a character not by line or whole text file should i use stream or text reader i know from docs that TextReader -> StreamReader and they both have function .read() so how should i decide which one. And should i use a cobination with stringbuilder when i want to count the number of words
4 Replies
mindhardt
mindhardt14mo ago
TextReader is an abstract class so you can't use it directly And StreamReader inherits from TextReader actually So SR is just a realization of TR
Camster
Camster14mo ago
If you want it to be efficient, you’ll want to read from disk in buffers, usually 4096 bytes
Spekulant
SpekulantOP14mo ago
by char will do thanks !close
Accord
Accord14mo ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server