DEV Community

yashaswi
yashaswi

Posted on

1

[Post 1]LINQ -Enumerable

[Post 1]LINQ -Enumerable

Enumerable is a data structures that can be iterated, counted or enumerated. Array, List, Dictionary are some data structures that are Enumerable.

In perspective of C# any Object that implements “*IEnumerable” *interface is an Enumerable. Array, List, Dictionary are some of the data structures that implement IEnumerable.

Every IEnumerable can support the use of “foreach()” *method for iterating the collection. [This post limits itself to the concept of IEnumerable and does not divulge into “*IEnumerable”.]

Documentation

IEnumerable is part of “System.Collections” *namespace. IEnumearble contains only a single method *“GetEnumerator()” *which returns an “*IEnumerator”.[A seperate post is being written on “IEnumerator” *which would be published shortly.]

namespace System.Collections
{
//
// Summary:
// Exposes an enumerator, which supports a simple iteration over a non-generic collection.
public interface IEnumerable
{
//
// Summary:
// Returns an enumerator that iterates through a collection.
//
// Returns:
// An System.Collections.IEnumerator object that can be used to iterate through
// the collection.
IEnumerator GetEnumerator();
}
}
view raw IEnumerable.cs hosted with ❤ by GitHub
namespace System.Collections
{
//
// Summary:
// Exposes an enumerator, which supports a simple iteration over a non-generic collection.
public interface IEnumerable
{
//
// Summary:
// Returns an enumerator that iterates through a collection.
//
// Returns:
// An System.Collections.IEnumerator object that can be used to iterate through
// the collection.
IEnumerator GetEnumerator();
}
}
view raw IEnumerable.cs hosted with ❤ by GitHub

A series of posts would follow this that talk about *“IEnumerator” , “Iterator Pattern” *and *“LINQ”.

The posts are written small intentionally. The purpose of these posts is to provide information in nuggets for faster assimilation, keeping it short and simple.

`

Top comments (0)