Skip to main content

Declare Initialized Field

In This Article

Declares a new field and initializes it with the selected parameter. Creates linked identifiers for the generated field references and drops a marker onto the initial method parameter reference.

#Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a method parameter within the method declaration.

#Example

private void TestMethod(int Param1)
{

}
Private Sub TestMethod(ByVal Param1 As Integer)

End Function

Result:

private int _Param1;
private int TestMethod(int Param1)
{
    _Param1 = Param1;
}
Private _param1 As Integer
Private Function TestMethod(ByVal Param1 As Integer) As Integer
    _param1 = Param1
End Function