IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesASP Classic  Print This     

Member Property

ASP Classic:   Property..Get..Let

ASP classic uses the property keyword and special Get and Let methods to both get and set the values of properties.

Syntax Example:
Class Cyborg
 Private FCyborgName
 
 Public Property Get CyborgName()
  CyborgName = FCyborgName
 End Property
 
 Public Property Let CyborgName(pCyborgName)
  FCyborgName = pCyborgName
 End Property
End Class




Cross Reference Examples:

C#:   no (), get, set

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).

Syntax Example:
public class Cyborg : System.Object
{
  private string cyborgName;
 
  public string CyborgName
  {
  get {return cyborgName;}
  set {cyborgName = value;}
  }

}
Corel Paradox:   Not Supported
Delphi:   property..read..write

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).

Syntax Example:
TCyborg = class(TObject)
private
  FCName: String;
public
  property CyborgName: String read FCName write FCName;
end;
Delphi Prism:   property..read..write

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).

Syntax Example:
Cyborg = class(System.Object)
private
  FCName: String;
public
  property CyborgName: String read FCName write FCName;
end;
VB.Net:   property, get, set

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).

Syntax Example:
Public Class Cyborg
Private FCyborgName As String
 
  Public Property CyborgName()
Get
Return F
CyborgName
End Get
 
Set(ByVal value)
F
CyborgName = value
End Set
End Property
End Class




Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]