Answer Posted / bipin
The IEnumerator interface provides iterative capability for
a collection that is internal to a class.
IEnumerator requires that you implement three methods:
The MoveNext method, which increments the collection
index by 1 and returns a bool that indicates whether the
end of the collection has been reached.
The Reset method, which resets the collection index to
its initial value of -1. This invalidates the enumerator.
The Current method, which returns the current object at
[position].
public bool MoveNext()
{
position++;
return (position < carlist.Length);
}
public void Reset()
{position = 0;}
public object Current
{
get { return carlist[position];}
}
IEnumerable interface
The IEnumerable interface provides support for the foreach
iteration. IEnumerable requires that you implement the
GetEnumerator method.
public IEnumerator GetEnumerator()
{
return (IEnumerator)this;
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is advantage of code behind coding in ASP.NET?
In ViewState How much lifespan items stored?
Where the cookie value is stored?
Can we add code files of different languages in app_code folder?
Can we use a static function with a non-static variable?
Why is it preferred to not use finalize for clean up?
Elaborate differentiation between Cache and Application?
How do sessions work?
What is voluum?
What is application in asp net?
What is a swagger in web api?
What is difference in .net 1.1 and .net 2.0?
Please brief not about xsd,xslt & xml?
Explain asp.net application life cycle?
Define data caching?