What are iterators?

Answer Posted / gp_bellamkonda

What Sumit suggested was correct.Adding few more points to
it.

--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


Please Help Members By Posting Answers For Below Questions

Can properties be overloaded in c#?

548


What is unsigned int?

525


Explain the functionalities of satellite assembly?

544


What is dictionary and hashtable in c#?

466


How do I create a multilanguage, single-file assembly?

492






What are constants in c#?

559


Explain about multithreading?

546


What is wpf c#?

489


What is for loop in c#?

501


What are the Types of instancing properties and explain each. Explain the difference between multiuse,singleuse and globalmultiuse and which is default

554


You are designing a user control. You created new property called backgroundimage which is of type image. You wanted to disable storing this property in the user’s form. How to achieve this?

518


Hi Friends, I am going through Siemens Interview Procedure from last 1+1/2 months. I went through 1 written + 2 Technical + 1 Managerial Round process after which I got call from HR informing that "you are selected and we would like to meet you for HR round". HR round was very nominal compared to MR. HR Round last for hardly 5 mins. They told me that you will get the final result on Friday. Still I have not received any feedback from them. Please help!!!

16609


Can we extend sealed class in c#?

488


Why we use extension method in c#?

506


Can a class be protected in c#?

486