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
- use
virtual
in base class - write
new
in derived class - any other (please suggests if have anything else)
Which will be the right way to solve this warning?