jenswinter.com
Software Development 24/7

Formatting Object Initializers

September 25, 2007 22:15 by Jens

I'm currently playing around with the Orcas Beta 2 and C# 3.0. As I'm experimenting with the new object initialization feature in C#, I'm wondering which coding style will be applicable and will prevail.

So here is the style from the C# 3.0 specification:

Project project = new Project { VersioningType = "SqlServerVersionsTable", DatabaseType = "SqlServer" };

But I'm not sure if this will be the best choice most of the time. So here some other styles to vote for:

Project project = new Project
{
    VersioningType = "SqlServerVersionsTable", DatabaseType = "SqlServer"
};

or

Project project = new Project
{
    VersioningType = "SqlServerVersionsTable",
    DatabaseType = "SqlServer"
};

or (my favorite for now)

Project project = new Project
    {
        VersioningType = "SqlServerVersionsTable",
        DatabaseType = "SqlServer"
    };

The time will tell which version really will be used by the majority of the developers.


Tags:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 7. 2009 09:49