- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the interface IEnumerable do in C#?
IEnumerable is an interface defining a single method GetEnumerator() that returns an IEnumerator interface. It is the base interface for all non-generic collections that can be enumerated.
This works for read-only access to a collection that implements that IEnumerable can be used with a foreach statement.
It has a single method −
GetEnumerator() − This method returns an enumerator that iterates through a collection.
The following is the implementation of the GetEnumerator() method of the IEnumerable interface in C# −
IEnumerator IEnumerable.GetEnumerator() { return (IEnumerator) GetEnumerator(); }
The following are the extension methods of the IEnumerable interface in C# −
Sr.No | Method Name & Description |
---|---|
1 | AsParallel() Enables parallelization of a query |
2 | AsQueryable() The method converts an IEnumerable to an IQueryable. |
3 | Cast<TResult>() The method casts the elements of an IEnumerable to the specified type |
4 | OfType<TResult>() Filters the elements of an IEnumerable based on a specified type. |
Advertisements