This is a wrong, totally wrong question, as nearly all questions about "difference". In this particular case, this is the same as asking "what is the difference between penguin and bird?" Penguin is a bird, and
FileStream
is a
Stream
:
https://msdn.microsoft.com/en-us/library/system.io.filestream%28v=vs.110%29.aspx[
^].
See also:
https://msdn.microsoft.com/en-us/library/d62kzs03%28v=vs.110%29.aspx[
^].
You really need to learn the basics of OOP.
In particular, you need to understand the
compile-time types vs
runtime types. In your first line, the constructor returns an instance of
FileStream
(as any constructor of the same time would do), but you abstract it up to the compile-time type
Stream
. Nevertheless, runtime type of the variable
s
is still
FileStream
. Please see:
https://msdn.microsoft.com/en-us/library/47ek66wy%28v=vs.110%29.aspx[
^].
And so on… Mind you, we are only discussing some prerequisites to OOP, but the "real" OOP plays fundamental role in these types; so you need to learn all those prerequisites (encapsulation, inheritance, and so on) really well, before you can really do any programming.
—SA