0

I am new to C# coding. I implemented following code and facing a warning.

class Base {
    public static Base Getinstance() {
        return new Base();
    }
}

class Derived : Base {
   // getting warning Derived.getInstance()' hides inherited member
   //'Base.getInstance()'. Use the new keyword if hiding was intended
   public static Derived Getinstance() {
        return new Derived();
   }
}

In order to remove the warning I have 2 options

  1. use virtual in base class
  2. write new in derived class
  3. any other (please suggests if have anything else)

Which will be the right way to solve this warning?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Suri
  • 3,287
  • 9
  • 45
  • 75

0 Answers0