Parameter types |
Top Previous Next |
What is translated > Routines > Parameter types
Parameters either are passed to routines by value or be reference.Strings are passed as references, but behave as if they were passed by value (because of its copy-on-write technique). Further there are constant parameters and untyped parameters. Different cases of single parameters and how they are translated are listed below. Array parameters are discussed in the array section.
The Delphi var keyword becomes to ref in C# and const doesn't exist in C#.
type
MyRecord = record end;
PInteger = ^Integer;
procedure Foo(param : Integer); procedure Foo(const param : Integer); procedure Foo(var param : Integer); procedure Foo(out param : Integer);
procedure Foo(param : String); procedure Foo(const param : String); procedure Foo(var param : String); procedure Foo(out param : String);
procedure Foo(param : Pointer); procedure Foo(const param : Pointer); procedure Foo(var param : Pointer); procedure Foo(out param : Pointer);
procedure Foo(param : PChar); procedure Foo(const param : PChar); procedure Foo(var param : PChar); procedure Foo(out param : PChar);
procedure Foo(param : PInteger); procedure Foo(const param : PInteger); procedure Foo(var param : PInteger); procedure Foo(out param : PInteger);
procedure Foo(param : MyRecord); procedure Foo(const param : MyRecord); procedure Foo(var param : MyRecord); procedure Foo(out param : MyRecord);
// untyped parameters procedure Foo(const param); procedure Foo(var param); procedure Foo(out param);
->
public static void Foo(int param); public static void Foo(int param); public static void Foo(ref int param); public static void Foo(ref int param);
public static void Foo(Pointer param); public static void Foo(Pointer param); public static void Foo(ref Pointer param); public static void Foo(ref Pointer param);
public static void Foo(string param); public static void Foo(string param); public static void Foo(ref string param); public static void Foo(ref string param);
public static void Foo(PChar param); public static void Foo(PChar param); public static void Foo(ref PChar param); public static void Foo(ref PChar param);
public static void Foo(Pointer<int> param); public static void Foo(Pointer<int> param); public static void Foo(ref Pointer<int> param); public static void Foo(ref Pointer<int> param);
public static void Foo(MyRecord param); public static void Foo(MyRecord param); public static void Foo(ref MyRecord param); public static void Foo(ref MyRecord param);
// untyped parameters public static void Foo(Pointer param); public static void Foo(ref Pointer param); public static void Foo(ref Pointer param);
Pointer, PChar and Pointer<T> are classes to simulate pointers. .
|
This page belongs to the Delphi2C# Documentation |
Delphi2C# home Content |