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 GuidesDelphi PrismLanguage Details  Print This     

Delphi Prism Language Details

Self Keyword

Delphi Prism:   Self

Within the implementation of a method, the identifier Self references the object in which the method is called. The Self variable is an implicit parameter for each object method. A method can use this variable to refer to its owning class.

To refer to the current instance of a class or structure, use the Self keyword. It provides a way to refer to the specific instance in which the code is currently executing. It is particularly useful for passing information about the currently executing instance.

You cannot use it with static method functions because static methods do not belong to an object instance. If you try, you'll get an error.

More Info / Comment




Cross Reference Examples:

Access VBA:   Me

Same as VB. The Me keyword is a built-in variable that refers to the class where the code is executing. For example, you can pass Me from one module to another.

Syntax Example:
Private Sub Command10_Click()
    MsgBox Me.Name 'Displays name of form (Form1 in this case).

End Sub
ASP Classic:   me

Same as VB. The Me keyword is a built-in variable that refers to the class where the code is executing.

Syntax Example:
Class Cyborg
 Public CyborgName
 
 Public Function IntroduceYourself() 
  'Using Me. Prints Cameron.
  Response.Write("Hi, my name is " & Me.CyborgName & ".")
  
  'The above is just a demo. You could also not include "Me." 
  'in this case because we are in context of Me now. Using Me 
  'makes more sense when you start to pass Me as a parameter 
  'to a method.
 End Function 
End Class
C#:   this

To refer to the current instance of a class, use the this keyword. The this keyword provides a way to refer to the specific instance in which the code is currently executing. It is particularly useful for passing information about the currently executing instance.

The this keyword is also used as a modifier of the first parameter of an extension method.

You cannot use this with static method functions because static methods do not belong to an object instance. If you try, you'll get an error.

More Info / Comment
C++:   this
C++/CLI:   this
Corel Paradox:   Self

A built-in object variable that represents the UIObject to which the currently executing code is attached.

Syntax Example:  
method pushButton(var eventInfo Event)
  msgInfo("", self.Name)
endMethod
Delphi:   Self

Within the implementation of a method, the identifier Self references the object in which the method is called. The Self variable is an implicit parameter for each object method. A method can use this variable to refer to its owning class.

Syntax Example:
ShowMessage('Self=' + Self.ClassName);
Java:   this
VB Classic:   Me

The Me keyword is a built-in variable that refers to the class where the code is executing. For example, you can pass Me from one module to another.

Syntax Example:
Private Sub Command4_Click()
  MsgBox Me.Name 'Displays name of form (Form1 in this case).
End Sub
VB.Net:   Me

To refer to the current instance of a class or structure, use the Me keyword. Me provides a way to refer to the specific instance in which the code is currently executing. It is particularly useful for passing information about the currently executing instance.

The Me keyword is also used as a modifier of the first parameter of an extension method.

You cannot use Me with static method functions because static methods do not belong to an object instance. If you try, you'll get an error.

Syntax Example:  
Sub SetBackgroundColor(FormName As Form)
  //FormName.BackColor = ...some color
End Sub
  
//Pass Me.
SetBackgroundColor(Me)




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


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