warning on accessing shared method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Why do I get a warning:
Access of shared member, constant member, enum member or nested type through
an instance; qualifying expression will not be evaluated

When accessing a shared method in the framework. (for example)
If Control.MouseButtons = MouseButtons.None Then....

What is the point of includes if they don't prevent this type of warning?
Will I always need to explicitly specify the name space?
If Control.MouseButtons = Windows.Forms.MouseButtons.None Then .....


Thanks for any insight into this!
 
iamahulk said:
Why do I get a warning:
Access of shared member, constant member, enum member or nested type through
an instance; qualifying expression will not be evaluated

When accessing a shared method in the framework. (for example)
If Control.MouseButtons = MouseButtons.None Then....

What is the point of includes if they don't prevent this type of warning?
Will I always need to explicitly specify the name space?
If Control.MouseButtons = Windows.Forms.MouseButtons.None Then .....

This is only because MouseButtons is the name of a property as well as
a type. If MouseButtons weren't a property in the current class you're
writing the code in, it would be absolutely fine. For instance, you
could write the above in a class which didn't derive from anything
other System.Object and it would be fine.
 
Back
Top