如何指定Name?不太明的你的意思。
_Test test;
int i=test.ID;

解决方案 »

  1.   

    _Test Test=new _Test();
    Test.Name[0]=??
      

  2.   

    public struct _Test
    {
        int ID;
        char[] Name=new char[40];
    }
      

  3.   

    struct _Test
    {
      int ID;
      char[] Name=new char[40];
    }
      

  4.   

    struct _Test
    {
      int ID;
      char[] Name=new char[40];
    }提示错误:结构中不能有实例字段初始值设置项( Error CS0573 )。
      

  5.   

    Why does it have to be a struct anyway?
    It's not a good design to have a struct hold a memory block. coz valuetype instances will be copied around when passed as parameters.
    Change struct to class will solve your problem. On the other hand, if you are trying to declear it as struct for some interop reasons, you may wanna try:
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=40)]
    byte[] Name;
      

  6.   

    我是一个C/C++程序员,出于兴趣(并不是工作的需要)学习C#。本想在C#中读取
    由C++生成的二进制文件(由struct描述),可就是找不到用C#读取二进制文件块到
    struct的方法。还望C#高手指点。
      

  7.   

    楼主是调用api吧?关于如何调用我这里找到一篇文章,楼主自己看吧:http://www.tongyi.net/article/20010923/200109232288.shtml另:楼上各位说的结构定义是不对的,在C#中,定义结构不能对其进行初始化,要定义只能这样:struct _Test
    {
      int ID;
      char[] Name;
    }
      

  8.   

    qqchen79(知秋一叶 [MS MVP]) (
    更正确