TextReader myreader = new StreamReader;

Is this inheritance...??

Thanks

No this is creating of a new instance of a TextReader object.
Check HERE what inheritance is.

Thanks for the reply..But if I am creating a new instance of a textreader object...

Why new streamreader passed in to it?

Thanks

The System.IO.TextReader (character oriented stream) is the abstract base/super class of System.IO.StreamReader. So, there is inheritance relationship between these two classes.

TextReader myreader = new StreamReader();

Above statement is an example of boxing. i.e Super class reference variable can hold a reference of sub-class object.

Thanks for replies...adatapost...

am I right in saying that myreader can hold a reference of streamreader type?

Thanks for replies...adatapost...

am I right in saying that myreader can hold a reference of streamreader type?

Yes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.