c#数据结构中的一个小问题

漫天雪飞 2011-03-09 09:37:33
public T this[int index]
{
get
{
return data[index];
}
set
{
data[index] = value;
}
}
这段代码中this[int index] 是什么意思?最好能把这段代码给我解释一下。谢谢!
...全文
95 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyerwing 2011-03-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 fangxinggood 的回复:]
属性的索引器。 你可以这么使用:
C# code
SomeClass obj = new SomeClass();
SomeOther other = obj[0];
[/Quote]
泛型集合 还有就是索引
小阳 2011-03-09
  • 打赏
  • 举报
回复
泛型集合 还有就是索引
机器人 2011-03-09
  • 打赏
  • 举报
回复
属性的索引器。 你可以这么使用:

SomeClass obj = new SomeClass();
SomeOther other = obj[0];
lizhibin11 2011-03-09
  • 打赏
  • 举报
回复
这个泛型类的中有一个集合data = new T[length],这个属性的作用是按照索引获取和得到T。
比如这个类的实例TheClass<T> theclass = new TheClass<T>,this[index]返回index处的T,调用时就是theclass[index]。

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧