Don’t use the private keyword

So another crazy suggestion for making C# a little less verbose. This time I am suggesting that you don’t use the private keyword.

I am confused that the private keyword even exists. Just leave it out and the compiler assumes a member is private. In fact when compared to other similar cases it gets even more confusing.

  • sealed vs. virtual: c# does not allow you to explicitly state a member is sealed. If you don’t have virtual it assumes your member is sealed.
  • static vs. instance: there is not even a keyword for “instance”. Either you state something is static or it is assumed to be instance.

So why allow me to add a keyword to a member that does nothing?

So moving forward let's just pretend the private keyword does not exist and never use it.

Oh and while we are on the topic don’t bother ever adding the internal keyword to a class. Classes are internal by default.

Note: yes I know read-only properties are an exception.

Posted by: Simon Cropp
Last revised: 20 Dec, 2011 07:38 PM History

Comments

No comments yet. Be the first!

No new comments are allowed on this post.