I\'m trying to make some code more readable. For Example foreach(var row in table) {...}
rather than foreach(DataRow row in table.Rows) {...}
.
The GetEnumerator method in your test class is not static, the extension method is. This doesn't compile either:
class test
{
}
static class x
{
public static IEnumerator
In order for the foreach syntax sugar to work your class must expose a public GetEnumerator instance method.
Edit:
As of C# 9.0, GetEnumerator
can be an extension method.