Property (programming)
Appearance
In a variety of object-oriented programming languages, property is a member of the class that provides the procedures for operating on a data member of that class. Properties provide a higher level of encapsulation compared to public fields.
Support in languages
Programming languages that support properies include Delphi (programming language), Visual Basic and C#. Some object-oriented languages, such as C++ and Java, don't support properties, and require the programmer to define a pair of accessor and mutator methods instead.
Example syntax
Delphi
type TPen = class
private
m_Color: Integer;
function Get_Color: Integer;
procedure Set_Color(RHS: Integer);
public
property Color: Integer read Get_Color write Set_Color;
end;
function TPen.Get_Color: Integer;
begin
Result := m_Color
end;
procedure TPen.Set_Color(RHS: Integer);
begin
m_Color := RHS
end;
Visual Basic
Private m_Color As Long
Public Property Get Color() As Long
Color = m_Color
End Property
Public Property Let Color(ByVal RHS As Long)
m_Color = RHS
End Property
C#
(will post in an hour)