Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Yield Statement
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01462394
Message ID:
01462404
Vues:
52
Thanks, but I have to say that this looks really confusing.



>I think this is explained a little better here http://msdn.microsoft.com/en-us/library/65zzykke.aspx, specially if you look at the middle example.
>
>You can use more than one yield statement in the same iterator as in the following example:
>
>
>public System.Collections.IEnumerator GetEnumerator()
>{
>    yield return "With an iterator, ";
>    yield return "more than one ";
>    yield return "value can be returned";
>    yield return ".";
>}
>
>
>You can then print the results using the following foreach statement:
>
>
>foreach (string element in new TestClass())
>{
>    System.Console.Write(element);
>}
>// Output: With an iterator, more than one value can be returned.
>
>
>This example displays the following text:
>
>With an iterator, more than one value can be returned.
>
>On each successive iteration of the foreach loop (or the direct call to IEnumerator.MoveNext), the next iterator code body
> resumes after the previous yield statement and continues to the next until the end of the iterator body is reached,
> or a yield break statement is encountered.
>
>Iterators do not support the IEnumerator.Reset method. To re-iterate from the beginning, you must obtain a new iterator.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform