Solved

Are various indentation styles typically shunned in C#?

Posted on 2012-03-10
2
242 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 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