System.io.stream is a abstract class then how httpwebrequest.getrequeststream() return the instance of stream class. i.e
Stream serverStream = request.GetRequestStream();
How stream class is initialized?
System.io.stream is a abstract class then how httpwebrequest.getrequeststream() return the instance of stream class. i.e
Stream serverStream = request.GetRequestStream();
How stream class is initialized?
httpwebrequest.getrequeststream() returns one of the concrete classes that inherit from the abstract class System.IO.Stream.
Stream is the abstract base class of all streams.
The Stream class and its derived classes provide a generic view of these different types of input and output, and isolate the programmer from the specific details of the operating system and the underlying devices.
and
httpwebrequest.getrequeststream
Gets a Stream object to use to write request data.
You have to create an instance of stream subclasses to get initialized.
go through this and this SO post for more .
You are confusing the type of a reference with the type of an object.
The fact that a method signature declares a particular type as its return type does not mean that instances returned will be of that exact type, they could be of a type derived from the one specified, as in you case.
Try this: Console.WriteLine(stream.GetType())
, should clear your thoughts a bit.