是否可以使用扩展方法来扩展索引器?我希望能够利用标题文字像这样从给定的DataGridViewRow的DataGridViewCell的获取单元格的值:C#扩展索引器?
object o = row["HeaderText"];
我有这样的代码
public static class Ext { public static object Cells(this DataGridViewRow r, string header) { foreach (DataGridViewCell c in r.Cells) { if (c.OwningColumn.HeaderText == header) { return c.Value; } } return null; } }
,我想类似的索引。谢谢。