Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • IEnumerable in C#

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 172
    Comment on it

    IEnumerable 

    IEnumerable is an interface which is implemented to support the ForEach semantics of Microsoft Visual Basic. It contains GetEnumerator method therefore exposes the enumerator, which in turn performs a simple iteration over a collection of specified type.

    Syntax of IEnumerable:-

    public interface IEnumerable

    Public method of IEnumerable:-

    IEnumerator GetEnumerator();
    

    Example of  IEnumerable:-

    Consider a list in C#:

    List<int> ages = new List<int>();
    ages.Add(10);
    ages.Add(20);
    ages.Add(30);
    ages.Add(40);
    ages.Add(50);
    

    Converting this list to IEnumerable:-

    IEnumerable<int> age_IEnumerable = (IEnumerable<int>)ages;
    foreach (int age in age_IEnumerable)
    {
        Console.WriteLine(age);
    }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: