1
Tech Writer 2.2k 1.6m 22y You are indeed able to extend the StreamReader class. For Example:
using System;
using System.IO;
public class MyCustomReader: StreamReader {
public MyCustomReader(string path): base(path) {}
public string Text() {
return "Hello World";
}
static void Main() {
MyCustomReader reader = new MyCustomReader(@"d:\word.doc");
Console.WriteLine(reader.Text());
}
}
1
Tech Writer 2.2k 1.6m 22y I don't think you can inherit from the StreamReader class. I am pretty sure that it is a sealed class, so you can only use it, not from it.
However, having said that, I also know that there is no parameter-less StreamReader contructor or function. You must provide, at bare minimum, a stream or a string.