How does a IEnumerator work in C# and not in Unity. For ex: If i have a function that has yield return 8; yield return 10; yield return 15; in 3 lines how does it work. I have answered it based on unity, that i never used numbers returning in a IEnumerator. But later i found out that these IEnumerators can be used in foreach loops like below. And it returns next value on every iteration. foreach(var number in GetNumbers()) { } IEnumerator GetNumbers() { yield return 1; yield return 2; yield return 3; }
AnswerBot
9mo
An IEnumerator in C# is used to iterate over a collection of objects one at a time, allowing for more efficient memory usage and performance.
IEnumerator is used to implement custom iterators in C# by ...read more
Help your peers!
Add answer anonymously...
Top Light & Wonder Lead Engineer interview questions & answers
Popular interview questions of Lead Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app