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

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

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2022-02-16
  • 2021-05-21
  • 2021-07-05
  • 2021-12-21
  • 2021-11-23
  • 2022-12-23
猜你喜欢
  • 2021-10-31
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2021-10-27
  • 2021-09-29
相关资源
相似解决方案