我试图做到这一点:阵列结构在C#
public static class GlobalVar
{
[DllImport("Export.dll")]
public static extern sentences Export();
public unsafe struct sentence_node
{
public sentence_node* next; // next node in the dictionary in the same level
public int sNum; // sentence number starting from 1
public int sLoc; // the location in the sentence (protien)
}
public unsafe struct sentences
{ // list of lists of sentences in which words exists.
public fixed sentence_node* sList[50];
public char[,] xplus = new char[50, 100];
public int wordCount;
}
}
,但我得到这两个错误:
错误1:
固定大小的缓冲区类型必须是一个如下所示:bool, double C:\ Users \ Aseel \ Documents \ Visual Studio 2010 \ Projects \ CBS \ CBS \ GlobalVar。 cs 40 22 CBS
错误2:
GlobalVar.sentences.xplus':不能有实例字段初始值设定在 结构C:\用户\ Aseel \文档\ Visual Studio的 2010 \项目\ CBS \ CBS \ GlobalVar.cs 41 24 CBS
该dll文件包含C语言的搜索算法,并有两个结构我上面加上其他结构,但我需要这两个来显示我的结果。有没有办法进入这些结构,而无需在C#中重新定义它们?
由以前我的意思是上面的代码.. – Aseel84
你应该考虑使用'class'。 (http://msdn.microsoft.com/en-us/library/y23b5415%28VS.71%29.aspx) – pascalhein
@csharpler:请不要发布.NET 1.1的链接。 –