请教一个c结构二级指针 转 c# 定义
原c结构体定义如下:
typedef struct {
LONG num_tables; /* number of tables */
CHAR **tables; /* table names */
CHAR *where; /* where clause */
} SE_SQL_CONSTRUCT;
转为c# (正确)
[StructLayout(LayoutKind.Sequential)]
public struct Se_Sql_Construct
{
public Int32 num_tables;
public IntPtr tables;
public string where;
}
CHAR **tables 转为 public IntPtr tables没有问题,程序运行正常,但赋值过程比较麻烦; 但我查资料说char ** 可转为string[] 但我的程序始终报错“尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”
请教大家
[解决办法]
这里http://www.qkhot.com/html/blog/82/296.htm有详细的讲解,用string[]一定是可以模拟CHAR**的。