Skip to main content

Add Setter

In This Article

Adds a setter to a property, and selects the contents of this setter.

#Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a property name within its declaration, provided that the property does not contain a setter.

#Example

private int _TestProperty;
public int TestProperty
{
    get
    {
        return _TestProperty;
    }
}
Private _TestProperty As Integer
Public ReadOnly Property TestProperty() As Integer
    Get
        Return _TestProperty
    End Get
End Property

Result:

private int _TestProperty;
public int TestProperty
{
    get
    {
        return _TestProperty;
    }
    set
    {_TestProperty = value;
    }
}
Private _TestProperty As Integer
Public Property TestProperty() As Integer
    Get
        Return _TestProperty
    End Get
    Set(ByVal value As Integer)_TestProperty = value
    End Set
End Property