Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve name conflict between member property and class name

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It needs to be fully referenced by namespace. Examples:

MyNamespace.Class1 // = Class1
MyNamespace.Class2 // = Class2
MyNamespace.Class1.Class2 // = the property called Class2 inside Class1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading