C# Default Access Modifier for Class Members - and drop that private habit!

The default access modifier for the members of a C# class (eg, fields, methods, and properties) is ‘private’. As such, I recommend never using the redundant ‘private’ keyword for class members. Leaving off the private nicely separates your privates from your public/inheritable interface in syntax highlighting. It also saves people having to read redundant code - you wouldn’t want your code to be full of un-needed casts, or redundant ‘this.’ references, would you?


Actions

Information

2 responses to “C# Default Access Modifier for Class Members - and drop that private habit!”

27 05 2008
Matt Dunn (11:51:19) :

Nooooooo, but then I have to remember that no access modifier means private! And StyleCop will complain :)

Cheers,
Matt

19 06 2008
Tim (16:56:56) :

Glad to see you dont like writing those extra chars either.

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>