Solved

Are various indentation styles typically shunned in C#?

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Video Player 12 27
C# guarantee sql connection close 6 50
Calculate number of nights between two dates 5 53
C# Formatting DateTime String Value 5 28
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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