what is ienumerable interface?

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


Please Help Members By Posting Answers For Below Questions

Which .NET framework supports Web API?

600


What is difference between session and cookies in asp net?

506


What is server side session management?

530


What is the function of new view engine in asp.net? : asp.net mvc

549


What is web api and why to use it?

562






Which method do you use to enforce garbage collection in .net?

522


How can we call webservices in Banking Applications? and where we are using it?

1538


What is a session government?

505


What is the use of session?

528


What is difference between URL and URI?

633


How do I use response redirect?

563


How do you deploy your asp.net application?

540


Can anyone please tell me that the question posted on this website are Sufficient for the interview with 2+ year experience in .net

1509


How does a content page different from a master page?

582


Explain the disadvantages of viewstate?

575