Home > Mobile >  How to solve name conflict between member property and class name
How to solve name conflict between member property and class name

Time:11-05

We call from static a member method of Class1 a static method of a Class2

public partial class Class1
{
  ...
  public static Class1Method()
  {
     Class2.StaticClass2Method();
  }
}

Due to a (generated) update Class1 has now a property called "Class2". We now get the compile error: An object reference is required for the non-static field, method, or property. How to solve this without renaming?

CodePudding user response:

It needs to be fully referenced by namespace. Examples:

MyNamespace.Class1 // = Class1
MyNamespace.Class2 // = Class2
MyNamespace.Class1.Class2 // = the property called Class2 inside Class1
  •  Tags:  
  • c#
  • Related