Solved

Are various indentation styles typically shunned in C#?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
which object should i use (efficiency) 5 46
C# Connection String for Oracle database is not working 22 93
DateTimepicker 4 33
Counting connections to SQL Server through C# 3 29
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

12 Experts available now in Live!

Get 1:1 Help Now