Re: recursive GetEnumerator()



colin wrote:
I dont think in this case it actually returns anything, at least not thats used.
if I try and return an IEnumerator it complains.

Yes, it does return an enumerator. (Or, at least, it works as if it returns an enumerator. I don't know exactly how it's implemented.)

yield return p.val;
Why is the code continuing after return? Did you ignore the compiler warning about unreachable code?

thats the nature of yield I beleive,

Yes, you are right. The code continues at that point for the next step in the enumeration.

--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: recursive GetEnumerator()
    ... thats used. ... if I try and return an IEnumerator it complains. ... it does return an enumerator. ... I gues IEnumerator is just a sort of keyword to say its not a normal ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: for vs foreach for array enumeration
    ... An enumerator is an object that implements the IEnumerator interface; ... MoveNext() must then be called to get to the first item) ... yield return item; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Returning an IEnumerator from a ServicedComponent
    ... > channel sink which means either the server has no registered server ... > Do I need to apply different attributes to the Enumerator class? ... somehow from MarshalByRefObject (usually done in your case by creating a ... and contained an implementation of IEnumerator that was created ...
    (microsoft.public.dotnet.framework.component_services)
  • Re: Interface features implemented without using Interface
    ... public object Clone() {... ... Enumerator (IEnumerable and IEnumerator). ... complain 'cause the class "does not implement the GetEnumerator() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: foreach enhancement
    ... >> supporting IEnumerable into the array without splitting it up into its ... Better would be IEnumerator instead of IEnumerable, ... > 1...1000) I see no reason to generate an object, instead a for loop like ... and for more complicated things I would create my own enumerator. ...
    (microsoft.public.dotnet.languages.csharp)

Loading