3 ms·
> I've had managers want developers to use this to signify calling a base class's method, which is incorrect. You should be using base. public class MyClas
by sebazzz 6y ago
> I've had managers want developers to use this to signify calling a base class's method, which is incorrect. You should be using base.
public class MyClass : YourClass {
public void MyMethod() {
if(!base.YourMethod()) return;
}
}
That is some dangerous advice! If you later decide to override the base class method, you're in for a treat! The non-overridden behavior is then used.
My rule is exactly the opposite. Only allow `base` in:
- Constructors
- Overrides
- jermaustin1 6y agoThat is perfectly fine, but in this case, the manager wanted this to explicitly signify base, If you didn't provide this, it meant it was a MyClass method. And I agree it is dangerous - going against conventions on giant projects with dozens of developers, is dangerous. Should have left off the base. and the this. everywhere, like Visual Studio recommends.