what is ienumerable interface?



what is ienumerable interface?..

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

More ASP.NET Interview Questions

Can two web application share a session and application variable ?

5 Answers   Satyam, V3 Engineers,


how to update data using store procedure

1 Answers  


Should I delete cookies?

0 Answers  


Which @page directive should you create an asynchronous page?

1 Answers  


Can we use multiple web.config files in an sigle appliction?

3 Answers   IBS,






what is stateless ?

2 Answers   TCS,


What are the steps involved to fill a dataset?

0 Answers  


Can you clarified A Web service can only be written in .NET or not?

0 Answers   Siebel,


What is mvc structure? given example? How to show gridview control from business components and using class object arrays?

3 Answers  


What is the lifespan for items stored in ViewState?

4 Answers   Siebel Systems,


Can we create a multiple user simultaneously ?

0 Answers   MCN Solutions,


How does Garbage collector(GC) works in .net

14 Answers   Accenture, HCL, Kekran Mekran, People Tech, Wipro,


Categories