Answer Posted / srinivas.r
An iterator is a section of code that returns an ordered
sequence of values of the same type.
An iterator can be used as the body of a method, an
operator, or a get accessor.
The iterator code uses the yield return statement to return
each element in turn. yield break ends the iteration. For
more information, see yield.
Multiple iterators can be implemented on a class. Each
iterator must have a unique name just like any class
member, and can be invoked by client code in a foreach
statement as follows: foreach(int x in
SampleClass.Iterator2){}
The return type of an iterator must be IEnumerable,
IEnumerator, IEnumerable<T>, or IEnumerator<T>.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between dataset and datatable in c#?
Why do we need constructor?
What is dependency in software?
How many types of namespaces available in version4?
What is the use of base keyword? Tell me a practical example for base keyword’s usage?
What is icollection in c#?
What are the Types of assemblies that can be created in dotnet
Explain About Postback
Is c sharp open source?
What is datacontract in c#?
What is dataadapter c#?
What is the symbol used for in c#?
Explain dataadapter.update method in .net?
Can I call a virtual method from a constructor/destructor?
Why to use “finally” block in c#?