C# Program to Implement IEnumerable Interface using LINQ

This is a C# Program to implement IEnumerable interface using LINQ.

Problem Description

This C# Program Implements IEnumerable Interface using LINQ.

Problem Solution

Here it exposes an enumerator, which supports a simple iteration over a non-generic collection.

Program/Source Code

Here is source code of the C# Program to Implement IEnumerable Interface using LINQ. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Implement IEnumerable Interface using LINQ
 */
using System;
using System.IO;
using System.Collections;
using System.Linq;
class program
{
    public static void Main(string[] args)
    {
        var t = typeof(IEnumerable);
        var typesIEnum = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => 
                         x.GetTypes()).Where(x => t.IsAssignableFrom(x));
        foreach (var types in typesIEnum)
        {
            Console.WriteLine(types.FullName);
        }
        Console.ReadLine();
    }
}
Program Explanation

This C# program is used to implement IEnumerable interface using LINQ. Here it exposes an enumerator, which supports a simple iteration over a non-generic collection. This method creates an instance for all implementations of the IEnumerable interface in any assembly within the current domain. It then returns an IEnumerable with all the instances which we need to setup.

advertisement
advertisement
Runtime Test Cases
 
System.Linq.Parallel.IndexedSelectQueryOperator`2
System.Linq.Parallel.IndexedSelectQueryOperator`2+IndexedSelectQueryOperatorResults
System.Linq.Parallel.IndexedWhereQueryOperator`1
System.Linq.Parallel.LastQueryOperator`1
System.Linq.Parallel.ReverseQueryOperator`1
System.Linq.Parallel.ReverseQueryOperator`1+ReverseQueryOperatorResults
System.Linq.Parallel.SelectManyQueryOperator`3
System.Linq.Parallel.SelectQueryOperator`2
System.Linq.Parallel.SelectQueryOperator`2+SelectQueryOperatorResults
System.Linq.Parallel.SingleQueryOperator`1
System.Linq.Parallel.SortQueryOperator`2
System.Linq.Parallel.SortQueryOperatorResults`2
System.Linq.Parallel.TakeOrSkipQueryOperator`1
System.Linq.Parallel.TakeOrSkipQueryOperator`1+TakeOrSkipQueryOperatorResults
System.Linq.Parallel.TakeOrSkipWhileQueryOperator`1
System.Linq.Parallel.WhereQueryOperator`1
System.Linq.Parallel.ListChunk`1
System.Linq.Parallel.Lookup`2

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.