I was wondering about this feature as well. Could the syntax look something like this:
public static class Extensions {
public static object Cell{
get(this DataTable t, int row, int column)
{ return t.Rows[row][column]; }
set(this DataTable t, int row, int column)
{ t.Rows[row][column] = value; }
}
}
// usage
dataTable.Cell[0, 2] = "Hello World";
The usage would be the same, but the compiler would just have to translate this new syntax and it differs from indexing syntax.
public static TimeSpan Minutes
{
get(this int i)
{ return new TimeSpan(0, i, 0); }
}
public static DateTime Ago
{
get(this TimeSpan ts)
{ return DateTime.Now.Subtract(ts); }
}
They still look like properties.
Andres