Skip to main content

Add Initialization

In This Article

Adds an initialization of a field to each constructor of a current type, and creates navigation links for the initialization values.

#Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a field that is declared without an initialization, provided that the active type contains at least one constructor.

#Example

class TestClass
{
    public TestClass()
    {

    }
    private int MyVar;             
}
Public Class TestClass
    Public Sub New()

    End Sub
    Private MyVar As Integer
End Class

Result:

class TestClass
{
    public TestClass()
    {
        MyVar = 0;
    }
    private int MyVar;             
}
Public Class TestClass
    Public Sub New()
        MyVar = 0

    End Sub
    Private MyVar As Integer
End Class