Answer Posted / puneet meena
while(get_next_record_from_database)
{ yield return your_next_record;}
It allows you to quickly create an object collection (an Enumerator) that you can loop through and retrieve records. The yield return statement handles all the of the code needed to create an enumerator for you.
The big part of the yield return statement is that you don't have to load all the of the items in a collection before returning the collection to the calling method. It allows lazy loading of the collection, so you don't pay the access penalty all at once.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Tell us the difference between managed and unmanaged code?
Please explain what is the difference between a class and an object?
What are the differences between an interface and an abstract class in .net?
What are the differences between user control and server control?
How to create multiple inheritance in c#, with example?
What is .net environment?
Can you write a class without specifying namespace?
Can a try block have more than one catch block?
How to create a key pair in .net?
Is .net core managed code?
Explain how to load the contents of an xml file into an xmldocument object?
Does .net supports destructors concept?
How do I use the thread pool?
Explain the difference between asp.net & vb.net and explain architecture?
Explain dataset.acceptchanges and dataadapter.update methods in .net?