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
How many namespaces are in .net version 1.1?
Explain .net framework overview?
How can you instantiate a tuple?
What is the use of UML in .Net
What is the difference between function and stored procedure?
Explain the procedure to add assemly to gac to make it shared one?
Explain assemblies in .net?
Which dll translate xml to sql in internet information server (iis)?
How to produce an assembly?
What is Complex Class in .NET?
How can I find out what the garbage collector is doing?
What class does icon derive from? Isn't it just a bitmap with a wrapper name around it?
which methos do you invoke on the dataadapter control to load your generated dataset with data?
Do I have any control over the garbage collection algorithm?
what are connection strings?