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

Explain the difference between array and linkedlist?

0 Answers  


In ViewState How much lifespan items stored?

0 Answers   Siebel,


What is the difference between managed and unmanaged code? *******

2 Answers   Patni,


Describe the sequence of action takes place on the server when ASP.NET application starts first time?

0 Answers   CDC,


Are cookies stored on server or client?

0 Answers  






What a diffgram is, and a good use for one?

0 Answers  


How asp.net mvc differs from asp.net web forms? : asp.net mvc

0 Answers  


What is .Net3.0 and .Net3.5? Describe something about that Features..

1 Answers  


What is content place holder?

0 Answers  


Explain the life cycle of an ASP .NET page.

2 Answers  


For a webapplication if i want to gice access controls like admin,users how can i give security like rolebased?

2 Answers   CTS, Syncfusion,


version information is mentioned in which file

3 Answers   AG Technologies,


Categories