拡張メソッドを使用してインデクサーを拡張することは可能ですか? 次のようなヘッダー テキストを使用してDataGridViewCell
、指定されたセルの値を取得できるようにしたいと考えています。DataGridViewRow
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;
}
}
同様のインデクサーが必要です。ありがとう。