private int _size;
public int Size
{
get
{
return _size;
}
set
{
if (value < 0)
{
_size = 0;
}
else
{
_size = value;
}
}
}
foo.Size++;
|
class-id Things.
01 _size binary-long private.
01 ReadOnly binary-long property with no set value 3.
01 ReadWrite binary-long property.
property-id Size binary-long.
*> Use property-value inside properties to
*> pass the value in or out
getter.
set property-value to _size
setter.
if property-value < 0
set _size to 0
else
set _size to property-value
end-if
end property.
method-id main static.
declare foo = new Things()
add 1 to foo::Size
display foo::Size
display foo::ReadOnly
set foo::ReadWrite to 22
end method.
end class.
|
Private _size As Integer
Public Property Size() As Integer
Get
Return _size
End Get
Set (ByVal Value As Integer)
If Value < 0 Then
_size = 0
Else
_size = Value
End If
End Set
End Property
foo.Size += 1
|