M
Mike
I'm using VS2005 beta 2.
(1) It looks like "foreach" is looking for an IEnumerable only, and not an
IEnumerator.
That means that class I use in the interation has to have GetEnumerator(),
rather than supporting the IEnumerator protocol (incl. automatically created
generator class using "yield return".) I can define GetEnumerator(), but
this forces me into one implementation (or an ugly class with state that
swiches and calls a sub-enumerator), rather than calling the IEnumerator
directly.
So I can't do:
public IEnumerator listForwards() { yield return 1; yield return 2; }
public IEnumerator listBackwards() { yield return 2; yield return 1; }
foreach ( int i in listForwards()) { ... }
but I'm forced to write:
public IEnumerator GetEnumerator() { return listForwards(); }
to get things to work, boxing me in to what GE() returns.
It's already bad enough that generator functions in c# are restricted to
being enumerators, I hope things aren't even more screwy.
Googling shows that the fomer should work in 2.0. (I know there's an issue
about not having a default GetEnumerator() in the new collections, but
that's a different issue.)
(2) I cannot create an empty winform user control, add it to the toolbox,
and drop it on a form -- either nothing happens, or an error is generated
about not being able to load the control (without other explanation.) The
same exersize works fine (obviously) in VS2003.
Please let me know if I'm misunderstanding things here or have done
something silly, or if the release bits will solve these problems...
thanks,
m
(1) It looks like "foreach" is looking for an IEnumerable only, and not an
IEnumerator.
That means that class I use in the interation has to have GetEnumerator(),
rather than supporting the IEnumerator protocol (incl. automatically created
generator class using "yield return".) I can define GetEnumerator(), but
this forces me into one implementation (or an ugly class with state that
swiches and calls a sub-enumerator), rather than calling the IEnumerator
directly.
So I can't do:
public IEnumerator listForwards() { yield return 1; yield return 2; }
public IEnumerator listBackwards() { yield return 2; yield return 1; }
foreach ( int i in listForwards()) { ... }
but I'm forced to write:
public IEnumerator GetEnumerator() { return listForwards(); }
to get things to work, boxing me in to what GE() returns.
It's already bad enough that generator functions in c# are restricted to
being enumerators, I hope things aren't even more screwy.
Googling shows that the fomer should work in 2.0. (I know there's an issue
about not having a default GetEnumerator() in the new collections, but
that's a different issue.)
(2) I cannot create an empty winform user control, add it to the toolbox,
and drop it on a form -- either nothing happens, or an error is generated
about not being able to load the control (without other explanation.) The
same exersize works fine (obviously) in VS2003.
Please let me know if I'm misunderstanding things here or have done
something silly, or if the release bits will solve these problems...
thanks,
m