Which ordering is preferred for the override
keyword and the access modifer (public
, private
, etc.) for methods? Both of the following seem to compile and do the same thing:
public override string ToString ()
{
return "access modifier first";
}
override public string ToString ()
{
return "override keyword first";
}
In Java, the order of keywords is typically enforced, so this flexibility seems startling. Apparently this flexibility is in Java, too (static public void main (String [] args)
works...).
ReSharper, a plug-in for VS which provides several coding assistants like extended auto-completion, places the access modifier first. This would indicate that even if the C# spec is more flexible, most people expect to see it this way.
It's odd though because to use ReSharper's auto-complete for a method, you would type in "override" and then IntelliSense gives a list of overridable methods. Then, when you pick one, it restructures the definition so the access modifier is first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With