我们课本上是这样写的private Es[]esmeb = new Es();for(int i =0;i<es.length;i++){esmeb[i].xxx  (这样就可以访问类里的属性)}这个是怎么实现的呢

解决方案 »

  1.   

    private Es[]esmeb = new Es[]{xxxx,xxxxx,xxxxx};
    不知道Es结构或者for循环对esmeb[i] = new Es();
      

  2.   

    T [] arr = new T[长度];for(int ofs = 0 ; ofs < 长度;ofs++)
    {
       arr[ofs] = new T();
    }or List<T> list = new List<T>();
    for(int ofs = 0 ; ofs < 长度;ofs++)
    {
       list.Add(new T());}
      

  3.   

    不需要什么泛型,只要给Es类型定义一个public的成员就可。比如:
    public string xxx="abc";也可以设置成属性
      

  4.   

    什么叫这个是怎么实现的?
    Es[] esmeb 是ES的数组啊,esmeb里面的每个元素都是Es
    通过下标esmeb[0]、esmeb[1]……就能取到Es对象,自然就能调用Es的属性了
      

  5.   


    代码才不骗人。书本与csdn则不是。
      

  6.   


    晕死!关键的差别是人家写的是private Es[]esmeb = new Es[]{};而不是什么private Es[]esmeb = new Es();Es内容已经不重要。你就假设它是随便一个(空的)自定义class好了。