Declare Getter
In This Article
Adds a getter to the write-only property, a reference to which is currently selected. Selects the contents of the generated getter 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 write-only property, provided that this reference is on the right side of an expression.
#Example
private int _MyProp;
public int MyProp
{
set
{
_MyProp = value;
}
}
private int TestMethod()
{
return │MyProp;
}
Private _MyProp As Integer
Public WriteOnly Property MyProp()
Set(ByVal value)
_MyProp = value
End Set
End Property
Private Function TestMethod() As Integer
Return │MyProp
End Function
Result:
private int _MyProp;
public int MyProp
{
get
{
return │_MyProp;
}
set
{
_MyProp = value;
}
}
private int TestMethod()
{
return MyProp;
}
Private _MyProp As Integer
Public Property MyProp() As Object
Get
Return │_MyProp
End Get
Set(ByVal value As Object)
_MyProp = value
End Set
End Property
Private Function TestMethod() As Integer
Return MyProp
End Function