Microsoft C# Coding Style Guidelines & Visual Studio

These days most software developers need deal with more than one software development technology and programming language on a day to day basis. This often means that they have to switch back and forth between coding styles, with this in mind I noticed that although the MS coding guidelines for C# in .NET recommend K&R style braces for code blocks, e.g:

 


if (sneeze) {
  nose.Blow();
}

 

By default Visual Studio’s auto code formatting stuff will format your code with braces on newlines, e.g.:

 


if (sneeze)
{
  nose.Blow();
}

 

Very interesting indeed, I wonder are there internal coding style conflicts within Microsoft…

2 replies
  1. Alxandr
    Alxandr says:

    Your code won’t compile, you forgot the semi-colon xD, thought I do agree it’s strange to see that microsoft recommends doing one thing only to do the opposite… It’s sort of the opposite of apple, where as when they recommend doing something, they just makes absolutely sure anything else is entirely impossible.

  2. Kevin Godden
    Kevin Godden says:

    Hi Alxandr, good call on the semi-colons, I have spent too much time lately programming in python, no type safety and no semi-colons! ;-)

    But you’re right it is good to be given a choice of styles….

Comments are closed.