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

Explain what is an assembly?

554


What parameters can you pass in the url of the api?

657


What are the advantages of using sql stored procedures instead of adhoc sql queries in an asp.net web application?

578


What is the use of global.asax file?

542


Describe SOA and the tenets of it?

552






Define msil.

539


Why is this service branded with windows livetm?

607


List the major built-in objects in asp.net?

542


What is asp.net localization?

499


Why and where this web.config file is used?

591


What are the different ways you would consider sending data across pages in ASP (i.e between asp to asp)?

556


Who is using asp.net?

501


Describe state management in asp.net?

548


What is semantic gap?

619


What is viewstate parameter?

519