c#linq返回记录(按单元格)-索引器和值
我努力为下面的任务找到一个解决方案 设置:c#linq返回记录(按单元格)-索引器和值,c#,linq,indexer,C#,Linq,Indexer,我努力为下面的任务找到一个解决方案 设置: class Records { Cells cells; } class Cell { string FieldName; string Value; } class Cells : Collection<Cell> { public Cell this[string FieldName] } list<Records> records; 你能帮我一下吗?谢谢 这可能是索引器的
class Records
{
Cells cells;
}
class Cell
{
string FieldName;
string Value;
}
class Cells : Collection<Cell>
{
public Cell this[string FieldName]
}
list<Records> records;
你能帮我一下吗?谢谢 这可能是索引器的代码
public Cell this[string fieldName]
{
get
{
return records.Where(t=>t.FieldName == fieldName).FirstOrDefault();
}
}
如果这是家庭作业,你的尝试在哪里?
public Cell this[string fieldName]
{
get
{
return records.Where(t=>t.FieldName == fieldName).FirstOrDefault();
}
}