If you are writing code in a class that inherits from a base class and you want to call a protected or public method on that base class, is it best (right or wrong or otherwise) to call base.MyProtectedMethod()
or this.MyProtectedMethod()
(in c#)? What would the difference be? Both seem to work.
For example:
public class MyBase()
{
....
protected void DoStuff()
{
// some stuff
}
}
public class MyChildClass() : MyBase
{
public MyNewMethod()
{
// do some work
this.DoStuff();
base.DoStuff();
}
}
Does this just to the same thing twice in MyNewMethod
?