Search code examples
c#asp.netdelphiprogramming-languages

Cross-language programming - list of equivalent types?


I do most of my development using Delphi (D7 specifically). I also do some secondary work with ASP.NET / C#. I'm finding myself fighting to convert code from one language to the other, as well as figuring out how to properly publish DLL functions in one side to be called from the other side.

I'm sure there must be some big dictionary of translations between languages - for example...

Original Delphi Source:

if X = 5 then begin
  S:= IntToStr(1);
end else begin
  S:= IntToStr(-1);
end;

C# Translation:

if (X == 5)
{
  S = (1).ToString();
}
else
{
  S = (-1).ToString();
}

Delphi DLL Function:

function DoSomething(const In: PChar; const zIn: Integer; 
  var Out: PChar; var zOut: Integer): Boolean; stdcall;

C# Import:

[DllImport("MyDll.dll", CharSet=CharSet.AnsiChar, 
  CallingConvention=CallingConvention.StdCall)]
public static extern bool DoSomething(in string In, in int zIn, 
  out string Out, out int zOut);

(Please forgive me if that's incorrect, I typed it by memory not by copy/paste)

I'd love to have some sort of equivalence dictionary between languages, so I know how to match one end up with the other. Anyone know of any good website or book?


Solution

  • I just stumbled across this article today, which covers basically exactly what I wanted to know.