tags:

views:

97

answers:

1

Can anyone help with this I really can't see what is wrong.

I have a set of classes all in the same namespace and assembly. One of these classes is static. Since it is declared in the same namespace and assembly as the other classes I would expect it to be accessible to them all.

However it turns out it is accessible to all bar one of them; ironically the one class that needs to use it most.

The name of the class is just not recognised (does not appear in intellisense) in the context of this class. In all other classes it is fine.

Does anyone have any ideas?
Have I missed or misunderstood something...?

+3  A: 

You probably have a member of that class with the same name as the static class, and that name takes priority.

Your options are any one of:

  • Rename the colliding member
  • Rename the static class
  • Reference the static class by its namespace-qualified name
  • Create a using alias (shown below) to give another name for accessing it

Code (I have to have this line or it thinks the code is a continuation of a bullet?):

using AliasName = Namespace.StaticClassName;
280Z28
Alas it was a name conflict. I did try commenting out all methods with a conflicting name but that did not help. Renaming the class fixed it and indeed should have tried that instead of commenting out anyway - much quicker. Morning coffee needed me thinks!
Kildareflare
Good psychic debugging!
Eric Lippert