首页 > 其他 > 详细

索引器&集合

时间:2020-04-22 19:15:14      阅读:56      评论:0      收藏:0      [点我收藏+]

索引器&集合配合使用,实现使用[]获取数据的目的

private List<DataModel> dataList;

public DataModel this[string name]
{
	get { return dataList.Find(x => x.Name == name); }
}

public DataModel this[int index]
{
	get { return dataList[index]; }
}

示例代码

IndexerAndCollection

索引器&集合

原文:https://www.cnblogs.com/Lulus/p/12743932.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!