With block equivalent in C#?

Although C# doesn’t have any direct equivalent for the general case, C# 3 gain object initializer syntax for constructor calls:

var foo = new Foo { Property1 = value1, Property2 = value2, etc };

See chapter 8 of C# in Depth for more details – you can download it for free from Manning’s web site.

(Disclaimer – yes, it’s in my interest to get the book into more people’s hands. But hey, it’s a free chapter which gives you more information on a related topic…)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)