Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Tell us the difference between managed and unmanaged code?

1020


Please explain what is the difference between a class and an object?

1048


What are the differences between an interface and an abstract class in .net?

1047


What are the differences between user control and server control?

1105


How to create multiple inheritance in c#, with example?

1061


What is .net environment?

1107


Can you write a class without specifying namespace?

1137


Can a try block have more than one catch block?

1121


How to create a key pair in .net?

1090


Is .net core managed code?

1006


Explain how to load the contents of an xml file into an xmldocument object?

982


Does .net supports destructors concept?

2064


How do I use the thread pool?

1036


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

999


Explain dataset.acceptchanges and dataadapter.update methods in .net?

1001