Use object initializer – Resharper suggestion

The second contains less characters and so is more compact to read. You don’t have to repeat myClass 2 more times, and the initialization logic is in one block.

It is really a syntactic sugar that doesn’t change a thing in the generated code. If you doesn’t like it, you can always disable the warning on ReSharper.

A longer post on the advantages of using Object Initializers here:

  • Setting properties via object initialization or not : Any difference ?
  • Is there any benefit of using an Object Initializer?

Leave a Comment

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