public struct JyotyoJyohou_M
        {
            public decimal dcMkg0; 
            public void InitstJyotyoM()
            {
                dcMkg0 = 0;
            }
        }public decimal[] GSJMdcMkg0;        public decimal[] GSJMdcMkg0
        {
            get
            {
                return stJyotyoM[a].dcMkg0;
            }
            set
            { 
            
            }
        }上面的代码在类c中
c cc=new c();
c.GSJMdcMkg0[a]=12;我在调用GSJMdcMkg0时怎样把a,传进来?

解决方案 »

  1.   

    class c {        private struct JyotyoJyohou_M
            {
                public decimal dcMkg0;
                public void InitstJyotyoM()
                {
                    dcMkg0 = 0;
                }
            }
            public c(int count) {
                if(count >= 0)
                    temp = new JyotyoJyohou_M[count];
            }
            private JyotyoJyohou_M[] temp;        public decimal this[Int32 index]
            {
                get
                {
                    if (0 <= index && index < temp.Length)
                        return temp[index].dcMkg0;
                    else return 0;
                }
                set
                {            }
            }
        }
      

  2.   

    你应该用this[int index]试试或者内部把GSJMdcMkg0的内容写成stJyotyoM[].dcMkg0项
      

  3.   

    如果
    public struct JyotyoJyohou_M
            {
                public decimal dcMkg0; 
                public decimal dcMkg1;
                public decimal dcMkg2;
                public void InitstJyotyoM()
                {
                    dcMkg0 = 0;
    dcMkg1 = 0;dcMkg1 = 0;            }
            }
    怎么办?新手