The source code to print a list of non-generic collections using LINQ in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
//Program to print the list of non-generic
//collections using LINQ in C#.
using System;
using System.IO;
using System.Linq;
using System.Collections;
class IEnumerableDemo
{
public static void Main(string[] args)
{
var Type = typeof(IEnumerable);
var IEnumType = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x =>
x.GetTypes()).Where(x => Type.IsAssignableFrom(x));
foreach (var type in IEnumType)
{
Console.WriteLine("##########"+type.FullName+"#########");
}
}
}
In the above program, we created the IEnumerableDemo class that contains the Main() method. Here we get the list of non-generic collections using LINQ than print them using the foreach loop on the console screen.
Program:
The source code to print a list of non-generic collections using LINQ in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created the IEnumerableDemo class that contains the Main() method. Here we get the list of non-generic collections using LINQ than print them using the foreach loop on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer