我要定义一个结构体数组,结构体中又有一个整数型数组,如何定义
例:
public struct st
{
  uint16[] a = new uint16[12];
}public class b
{
  struct st[] c = new st[18];
}引用的时候这样用 b.c[0].a[8]被告诉结构体中不能实例化,该怎么定义

解决方案 »

  1.   


            public struct st
            {
                public UInt16[] a;           
            }        public class b
            {
              public st[] c = new st[18];          public b()
              {
                  for (Int32 i = 0; i < c.Length; i++)
                  { 
                    c[i].a =  new UInt16[12];
                  }
              }
            }
            static void Main(string[] args)
            {
                b b1 = new b();            Console.WriteLine(b1.c[0].a[8]);
            }
      

  2.   

    public struct st
    {
      uint16[] a ;
    }public class b
    {
      struct st[] c = new st[18];
      c[0].a = new unint16[4];
      c[0].a[0] = 1;
     
    }