因为这只是个例子,实际上上面的名字是完全不一样的,我为了简化才写Region1、Region2、Region3

解决方案 »

  1.   

    public struct Region
    { public int[] ID;
    public string[] Item;
    public bool[] Default;
    public int Count;public Region()
    {}
    }象类一样实例化使用
      

  2.   

    参数就是Region1、Region2、Region3等任意一个
      

  3.   

    Region region1 =  new Region()
    Region region2 =  new Region()
    Region region3 =  new Region()
      

  4.   

    public class region
    {
    public Region
    {
    public int[] ID;
    public string[] Item;
    public bool[] Default;
    public int Count;
    }
    }
    public class App
    {
    private System.ComponentModel.Container myContainer;
    public app()
    {
    myContainer = new System.ComponentModel.Container();}
    public void InstanceNewRegion()
    {
    region temp = new region();
    temp.Count = 1;
    myContainer.Add(temp);
    }
    }
      

  5.   

    不是那个意思,我是想像以下的结果一样:
    private void aa(Region x,int i)
    {
        x.Count = i;
    }aa(Region1,5);
    aa(Region2,8);
    aa(Region3,10);
      

  6.   

    luaiping(风起云涌) 
    的写法没有问题可以实现
      

  7.   

    我要定义的是公用变量,要在任何一个窗体都能调用到它的值
    Region region1 =  new Region()
    Region region2 =  new Region()
    Region region3 =  new Region()
    可以吗?
      

  8.   

    使用结构数组
    Region [] regions = new Region[3];
    regions[0] = regions1;
    regions[1] = regions2;
    regions[2] = regions3;
      

  9.   

    我现在这样做,但是在别的窗体调用的时候不知道怎么才能实现:k1.Count,好像在K1后按“.”没东西可选
    public struct kk
    {
        public static int[] ID;
        public static string[] Item;
        public static bool[] Default;
        public static int Count;
        
        public kk(){}
    }public static kk k1 = new kk();
      

  10.   

    和声明类及类的实例一样的,C++及C#里类的灵感就是来字C的结构的。
      

  11.   

    编译出错
    public struct kk
    {
        public static int[] ID;
        public static string[] Item;
        public static bool[] Default;
        public static int Count;
        
        public kk(){}
    }public static kk k1 = new kk();“public kk(){}”结构不能包含显式的无参数构造函数
      

  12.   

    同意 luaiping(风起云涌) 的写法。
      

  13.   

    估计楼主想用的是多态吧?
    不要用结构体了,直接用类吧.
    public class regions
    {
    }
    public class regions1:regions
    {
       public count
       regions1(int count)
       {
         this.count = count;
       }
    }
    public class regions2:regions
    {
       public count
       regions2(int count)
       {
         this.count = count;
       }
    }
    public class regions3:regions
    {
       public count
       regions1(int count)
       {
         this.count = count;
       }
    }
    public void Operate(regions,int x)
    {
       regions.count = x;
    }
      

  14.   

    编译出错
    public struct kk
    {
        public static int[] ID;
        public static string[] Item;
        public static bool[] Default;
        public static int Count;
        
        public kk(){}
    }public static kk k1 = new kk();“public kk(){}”结构不能包含显式的无参数构造函数
      

  15.   

    public struct kk
    {
        public static int[] ID;
        public static string[] Item;
        public static bool[] Default;
        public static int Count;
        
        public void kk(){}
    }
      

  16.   

    不要用static 
    当然出错
      

  17.   

    public struct kk
    {
        public static int[] ID;
        public static string[] Item;
        public static bool[] Default;
        public static int Count;
        
        public kk(){}
    }
    你这样写ID,Item等是属于这个类,而不是类的实例