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

public class ExampleIterator : IEnumerable {
public IEnumerator GetEnumerator() {
yield return 1;
}
}

The class ExampleIterator implements the IEnumerable
interface, which requires the GetEnumerator method to be
implemented. The GetEnumerator method returns an
IEnumerator instance. In the implementation of
GetEnumerator, the value 1 is returned rather than an
IEnumerator interface instance. This is odd, because how
can a value type be returned when a reference type is
expected? The magic is the yield keyword, which provides
the missing code in the form of generated IL.

The yield keyword is a compiler directive that generates a
very large chunk of IL code. Using ILDASM.exe it is
possible to reverse engineer what the compiler generated

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain me what is an anonymous method and how is it different from a lambda expression?

987


Is .net a language?

1010


What is the difference between response.redirect & server.transfer?

1122


Explain asp.net?

1076


Explain the difference between task and thread in .net?

935


which methos do you invoke on the dataadapter control to load your generated dataset with data?

1042


Can you create instance of a class which has private constructor?

1014


What is the use of activex control in .net?

1034


Explain the difference between static page and dynamic page?

965


What are the main components in .net?

1012


Do you know the difference between the stack and the heap?

991


Is there any attempt system for microsoft technology papers?

1798


what user controls are and what server controls are and the differences between the two.

2021


I am constantly writing the drawing procedures with system.drawing.graphics, but having to use the try and dispose blocks is too time-consuming with graphicsobjects. Can I automate this?

1007


Define satelite assembly?

1045