| layout | page |
|---|---|
| title | CC0009 |
| tagline | ObjectInitializerAnalyzer |
|TypeName|ObjectInitializerAnalyzer | |Check Id | CC0009 | |Category | Style | |Severity | Warning |
When possible an object initializer should be used to initialize the properties of an object instead of multiple assignments.
{% highlight csharp %} Person p; p = new Person(); p.Name = "Mahmoud"; p.Age = 25; {% endhighlight %}
A code fix will be presented to you that will transform the code:
{% highlight csharp %} Person p; p = new Person() { Name = "Mahmoud", Age = 25 }; {% endhighlight %}

- CC0008 - Use object initializer (local declaration)
TBD