Which is recommended: "static public" or "public static"

Viewed 24424

If you have a class member that is static and public. Would you write static public or public static? I know they are the same. But is there some recommendation / best practice for writing this?

4 Answers

"public static" is far more common, so you might want to go with that just to increase readability for programmers who never stumbled upon "static public".

see this question

If you download the Microsoft StyleCop Visual Studio addin, it can validate your source code against the rules Microsoft use. It likes the access modifier to come first.

When nothing else matters, go with consistency. In this case the rest of the world uses public static, so I'd go with that too just to avoid unnecessary surprise in those reading your code.

Related