Solved

Are various indentation styles typically shunned in C#?

Posted on 2012-03-10
2
239 Views
Last Modified: 2012-03-11
Are various indentation styles outside the Allman style typically shunned in the C# community?

I'm trying to figure out whether to get used to the Allman style in case I ever get a .Net development job.

http://en.wikipedia.org/wiki/Indent_style
0
Comment
Question by:Eindoofus
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 37705594
I actually use that style myself, because I find it easiest to read and update.
moreover, I often put a // comment at the closing bracket.

if (condition)
{
 . ..
} // if (condition)

which is especially useful with longer and deeply included conditions .
better would be the use of #region ... #end region, but more to type and maintain ..
0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 37706287
The Allman style is default in VS and in all newer documentation from MS, so I adopted it easily as I came from VB/VBA, thus had no other preferences for curly brackets.

The main advantage is that namespace and classes and methods are clearly lined up using this style and, when used at that level, why not use it throughout.

Some exceptions exist, however, where all the empty lines doesn't add anything, for example:

public DbSet<Sample> Samples { get; set; }

/gustav
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now