日期:2014-05-19  浏览次数:20729 次

一个索引器问题,请大家帮忙啊
using   System;
using   System.Collections.Generic;
using   System.Text;

namespace   信号测控
{
        public   class   Channels           {
                public   Channel   this[int   i]
                {

                        get
                        {
                                                             
                        }
                     
                }

                public   int   Count;
               

        }
}

这个是我建索引器的类,get{},里面应该返回一个什么值呢,我是新手,请大家帮忙了

------解决方案--------------------
你的类里应该有一个数组(简单点是数组,复杂了可以是集合),return的是数组中的某项

using System;
using System.Collections.Generic;
using System.Text;

namespace 信号测控
{
public class Channels {
public Channel this[int i]
{

get
{
return a[i];
}

}
private int a = new int[5];
public int Count;


}
}