Decompose Initializer
In This Article
Converts an object initializer to the object constructor call, followed by lines that initialize object properties. Activates Linked Identifiers for the object name.
#Availability
Available from the context menu or via shortcuts:
- when the cursor is placed on the name of the initialized object.
#Example
static Person CreatePerson()
{
return new │Person("Santa Claus") { Age = Int32.MaxValue };
}
Public Function CreatePerson() As Person
Return New │Person With {.Age = Integer.MaxValue}
End Function
Result:
static Person CreatePerson()
{
var objVar = new Person("Santa Claus");
objVar.Age = Int32.MaxValue;
return objVar;
}
Public Function CreatePerson() As Person
Dim objVar = New Person
With objVar
.Age = Integer.MaxValue
End With
Return objVar
End Function