what is yield keyword in .Net?

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


Please Help Members By Posting Answers For Below Questions

What tags do you need to add within the asp:datagrid tags to bind columns manually.

1489


What is difference between .net core and .net standard?

495


Explain the difference between asp.net & vb.net and explain architecture?

548


Explain me why do we use msmq?

577


What is Code group in .Net with respect to CAS

1577






What is meant by globalization and localization?

587


Describe the difference between inline and code behind which is best in a loosely coupled solution?

2134


What is .net latest version?

554


Explain me how does linq work?

594


Tell me about secure socket layer? How to make use of the technology?

556


Tell us what do the following acronyms in .net stand for: il, cil, msil, cli and jit?

526


What is Ajax design pattern in .NET?

659


How will you load dynamic assembly? How will create assemblies at run time?

1623


What are asp.net authentication providers and iis security?

539


What is view state in .net?

617