Namespace and class (?)

This is a bad title for the question, but I'm not quite sure about the best.

I have a namespace called Globals with class X in it. I also have a class called Globals. When I try to access Globals.X.StaticMember, it tries to access the Globals.X class and complains that X does not exist. How to reference the Globals namespace - ie :: Globals.X.StaticMember (:: does not compile).

+7
c #
source share
3 answers

Try global::Globals.X.StaticMember .

And the Globals are Evil!

+11
source share

Eric Lippert recently posted this on his blog. Four blog posts though, check this out . Start with the first part.

+8
source share

Eric Lippert recently had a blog series describing the problems you face when using the same name for a class and namespace, explaining this statement from the Framework Design Guide in Section 3.4:

"Do not use the same name for the namespace and type in this namespace."

See various posts here:

Do not call the class the same as its namespace ( Part 1 , Part 2 , Part 3 , Part 4 )

+1
source share

All Articles