首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

一个索引器有关问题,请大家帮忙

2012-02-15 
一个索引器问题,请大家帮忙啊usingSystemusingSystem.Collections.GenericusingSystem.Textnamespace信

一个索引器问题,请大家帮忙啊
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;


}
}

热点排行