L
Larry Lard
Today I discovered that a syntax that I thought was forbidden in C# but
allowed in VB.NET (and I _don't like_ that it's allowed in VB.NET) is
actually allowed in C#. Which confused me. The syntax in question is
referring to static members of a class *from a subclass*.
(Now, I know for sure there's a similar difference, in that VB.NET
allows/ed you to invoke static members from an instance member, whereas
C# has always required you to give the class name. This is different)
My usual example for this has always been
.... = Bitmap.FromFile(FileName)
I hate seeing this (or things like it) in VB.NET because it's
completely misleading. FromFile is a method of *Image* and it returns
an *Image*, but when you _read_ 'Bitmap.FromFile' you _think_ - oh
that's going to give me a bitmap from a file. hang on, why am I getting
an assignment error?'. Another problem is this: open your MSDN Library,
go to the Index, and type Bitmap.Fromf ... wait a minute ... confusion
results!
But it seems C# is perfectly happy with this (not even a warning)?! So
where did I get the idea it wasn't? And why is this allowed?
allowed in VB.NET (and I _don't like_ that it's allowed in VB.NET) is
actually allowed in C#. Which confused me. The syntax in question is
referring to static members of a class *from a subclass*.
(Now, I know for sure there's a similar difference, in that VB.NET
allows/ed you to invoke static members from an instance member, whereas
C# has always required you to give the class name. This is different)
My usual example for this has always been
.... = Bitmap.FromFile(FileName)
I hate seeing this (or things like it) in VB.NET because it's
completely misleading. FromFile is a method of *Image* and it returns
an *Image*, but when you _read_ 'Bitmap.FromFile' you _think_ - oh
that's going to give me a bitmap from a file. hang on, why am I getting
an assignment error?'. Another problem is this: open your MSDN Library,
go to the Index, and type Bitmap.Fromf ... wait a minute ... confusion
results!
But it seems C# is perfectly happy with this (not even a warning)?! So
where did I get the idea it wasn't? And why is this allowed?