首页 新闻 会员 周边

关于创建索引的代码实现

0
悬赏园豆:50 [已关闭问题] 关闭于 2011-07-27 16:53

看了半天索引的创建部分,还是没能搞明白是如何代码实现的……求大师指教!

sandwich的主页 sandwich | 初学一级 | 园豆:140
提问于:2011-07-27 16:50
< >
分享
所有回答(1)
0

索引器吗?

class SampleCollection<T>
{
private T[] arr = new T[100];
public T this[int i]
{
get
{
return arr[i];
}
set
{
arr[i]
= value;
}
}
}

// This class shows how client code uses the indexer
class Program
{
static void Main(string[] args)
{
SampleCollection
<string> stringCollection = new SampleCollection<string>();
stringCollection[
0] = "Hello, World";
System.Console.WriteLine(stringCollection[
0]);
}
}

nordson | 园豆:187 (初学一级) | 2011-07-27 16:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册