我有一个函数,它带有2个参数c
。他们都是char *
。其中 一个是输入,另一个是输出和我不知道我应该怎么填第二个(输出),请帮助我发送char *到字符串c#
// C
void func1(char * i_szInput , char * o_szOutput)
{
printf("%s\n" , i_szInput);
strcpy(o_szOutput , "Hello");
}
// C#
[DllImport("Test.dll")]
public static void func1([MarshalAs(UnmanagedType.LPStr)] string str1,
[MarshalAs(UnmanagedType.LPStr)] string str2);
// .......
string str = null;
func1("mytest" , str);
你应该使用'StringBuilder' – Thomas 2012-08-01 07:06:14