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

Parameters (C# and Delphi Cross Reference Guide)

By Mike Prestwood

C# versus Delphi: A side by side comparison between C# and Delphi.

 
Language Details
 

Language Details is kind of a catch all for stuff that didn't make it into language basics nor any other category.

Parameters

[Other Languages] 
C#: 

In C# the data type of each parameter must be specified, even if adjacent parameters are of the same type. To pass a parameter by reference, use the ref or out keyword.

Syntax Example:

integer Add(int a, int b)

Delphi:   var, const

Object Pascal allows parameters of the same type to be listed together, separated by commas, and followed with a single data type (more params of different data types can follow, after a semi-colon).

Delphi also supports default parameters (a form of overloading).

By Reference or Value (and by constant): The default for parameters is by value. For by reference, add var in front of the parameter. Object Pascal also offers constant parameters where you add const in front of the parameter. A constant parameter is like a local constant or read-only parameter the compiler can optimize. You cannot assign a value to a constant parameter, nor can you pass one as a var parameter to another routine. (But when you pass an object reference as a constant parameter, you can still modify the object's properties.)

Syntax Example:
function Add(a, b: integer) : integer; 
begin
  Result := a + b;
end;
 
procedure ReplaceTime(var pDT: TDateTime; const pNewDT: TDateTime);
begin
end;












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


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