C# - what type equivalent to PChar

Giganews Newsgroups
Subject: C# - what type equivalent to PChar
Posted by:  Alan Tse (alan_NO_SPAM_plt…@yahoo.com.au)
Date: Thu, 1 Jul 2010

Which data type should be used to call a API of parameter type as PChar?

I got a DLL function one of the parameter of type PChar,
eg

in Delphi DLL

function GetMyNickName(aName: PChar): PChar; stdcall;

The function will return my nickname.

So in C#, how do I call this DLL export function?

I tried:
string myName;
string nickName;

myName = "Eric Tony";
nickName = GetMyNicName(myName);

I got run time error, say something about the signature does not match.
The problem definitely about the parameter as I tried export function with
no parameter first, then modify to add a parameter.

Replies