Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of 'enumerator' in C#

Tags:

c#

What is the meaning of enumerator in C#?

like image 430
Niraj Choubey Avatar asked Aug 05 '10 13:08

Niraj Choubey


People also ask

How do you define enumeration?

An enumeration is a complete, ordered listing of all the items in a collection. The term is commonly used in mathematics and computer science to refer to a listing of all of the elements of a set.

What is enumerator used for?

An enumeration, or Enum , is a symbolic name for a set of values. Enumerations are treated as data types, and you can use them to create sets of constants for use with variables and properties.

What is the enumerator data type?

An enumeration is a data type that consists of a set of named values that represent integral constants, known as enumeration constants. An enumeration is also referred to as an enumerated type because you must list (enumerate) each of the values in creating a name for each of them.

What is enumeration explain with example?

An enumeration is used in any programming language to define a constant set of values. For example, the days of the week can be defined as an enumeration and used anywhere in the program. In C#, the enumeration is defined with the help of the keyword 'enum'.


1 Answers

An enumerator helps you enumerate (iterate) over a collection of items.

You can infer the purpose by simply looking at the members of the IEnumerator Interface. More specifically, the Enumerator knows exactly where you are in the collection (the current item) and where the next item is (the MoveNext method).

Check out the Wikipedia article on the Iterator:

Iterator - Wikipedia

like image 198
Justin Niessner Avatar answered Sep 17 '22 15:09

Justin Niessner