What is the added value of using object initializer?

Wednesday, July 9, 2014

What is the added value of using an object initializer? Is there any difference using it on value types compared to reference types?


I have installed ReSharper recently, and for the following example:



var response = new Response();
response.value = "My value";


My code is transformed to this:



var response = new Response()
{
response.value = "My value",
};


Personally I find it harder to follow the code when the initializer is too big.







http://ift.tt/1rReqSw