Declare Setter
In This Article
Adds a setter to a read-only property whose reference is currently selected. Selects the generated setter contents, and drops a marker onto the initial property reference.
#Availability
From the context menus or via shortcuts:
- when the edit cursor or caret is on a reference to a read-only property, providing that this reference is on the left side of an expression.
#Example
private string _MyProperty;
public string MyProperty
{
get
{
return _MyProperty;
}
}
private void TestMethod(string param)
{│MyProperty = param;
}
Private _MyProperty As String
Public ReadOnly Property MyProperty() As String
Get
Return _MyProperty
End Get
End Property
Private Sub TestMethod(ByVal Param As String)│MyProperty = Param
End Sub
Result:
private string _MyProperty;
public string MyProperty
{
get
{
return _MyProperty;
}
set
{│_MyProperty = value;
}
}
private void TestMethod(string param)
{
MyProperty = param;
}
Private _MyProperty As String
Public Property MyProperty() As String
Get
Return _MyProperty
End Get
Set(ByVal value As String)│Throw New NotImplementedException()
End Set
End Property
Private Sub TestMethod(ByVal Param As String)
MyProperty = Param
End Sub