views:

157

answers:

3

what is considered best practice from a code readability standpoint regarding spacing?

Are there any really good C# style guides out there?

A: 

Checkout StyleCop It analyzes your code for MS standards

taylonr
+1  A: 

A good, short, practical one is here: http://blogs.msdn.com/kirillosenkov/archive/2009/03/12/kirill-s-whitespace-guidelines-for-c.aspx

In short, have the amount of whitespace that is easy on eye. In C#, you'll have less whitespace than in some other languages because many lines consist only of curly braces. Leaving no blank lines can still result in plenty of white space. I also like to keep very related lines of code right up next to each other, making paragraphs in a sense.

There one reason for taking out blank lines that's not okay: to fit more code on your screen. If you're doing that, your code is probably not organized well, with functions too long.

Patrick Karcher
A: 

The best document on C# coding style I have seen is Lance Hunt's C# coding standards document, which can be found here:

http://weblogs.asp.net/brijmohan/archive/2008/10/10/c-coding-standards-by-lance-s.aspx

As far as whitespacing goes specifically, I am of the opinion that you use your own best judgement with respect to readability, although Krill's guide (mentioned in one of the other answers) is very representative of good whitespace style.

Robert Harvey