是否可以使用擴展方法來擴展索引器?我希望能夠利用標題文字像這樣從給定的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; } }
,我想類似的索引。謝謝。