The C# function is not corresponding to the Delphi one. How can it be
StringBuilder
, ever? Last parameter is not by ref but by value.
Try
public static extern Int32 foo(
Int32 pass1, Int32 pass2,
string txtToConvert, string convText,
Int32 scriptCode);
I'm not really sure about one of the parameters of the type
PChar
. If one of the parameters is meant to be output, probably both signatures are incorrect.
If last parameter should be by reference, it could be
var
or
const
in Delphi (yes, Delphi has a weird feature:
const
before a parameter means "constant reference", not just constant), and in C# in should be
out
or
ref
(it only depends on function implementation semantic and affects the usage by the caller).
—SA