VB.Net uses a special property keyword along with special get and set methods to both get and set the values of properties. For a read-only property, leave out the set method. The value keyword is used to refer to the member field. Properties can make use of any of the access modifiers (private, protected, etc).
My preference for VB.Net code is to start member fields with "F" ("FName" in our example) and drop the "F" with properties that manage member fields ("Name" in our example).
Public Class Cyborg Private FCyborgName As String
Public Property CyborgName() Get Return FCyborgName End Get
Set(ByVal value) FCyborgName = value End Set End Property
End Class
ASP classic uses the property keyword and special Get and Let methods to both get and set the values of properties.
Class Cyborg Private FCyborgName Public Property Get CyborgName() CyborgName = FCyborgName End Property
Public Property Let CyborgName(pCyborgName) FCyborgName = pCyborgName End Property
In C#, parens indicate a method and the lack of parens indicate a property. You use special get and set methods to both get and set the values of properties.
C# 3.0 introduced auto-implemented properties for use when no additional logic is required.
pulic int VendorID {get; set;}
For a read-only property, leave out the set method.
The value keyword is used to refer to the member field. Properties can make use of any of the access modifiers (private, protected, etc). It is common to use a lowercase member names for member fields ("name" in our example) and uppercase properties to manage member fields ("Name" in our example).
public class Cyborg : System.Object{ private string cyborgName;
public string CyborgName { get {return cyborgName;} set {cyborgName = value;} }}
Delphi uses a special property keyword to both get and set the values of properties. The read and write keywords are used to get and set the value of the property directly or through an accessor method. For a read-only property, leave out the write portion of the declaration.
You can give properties any visibility you wish (private, protected, etc). It is common in Delphi to start member fields with "F" ("FName" in our example) and drop the "F" with properties that manage member fields ("Name" in our example).
TCyborg = class(TObject)private FCName: String;public property CyborgName: String read FCName write FCName;end;
Like Delphi, Delphi Prism uses a special property keyword to both get and set the values of properties. The read and write keywords are used to get and set the value of the property directly or through an accessor method. For a read-only property, leave out the write portion of the declaration.
Prism also supports a shortcut syntax called implicit fields (known as auto-generated properties in C#):
property CyborgAge: Integer;
You can give properties any visibility you wish (private, protected, etc). It is common in Delphi and Delphi Prism to start member fields with "F" (FCName in our example) and drop the "F" with properties that manage member fields (CyborgName in our example).
Cyborg = class(System.Object)private FCName: String;public property CyborgName: String read FCName write FCName;end;