Q:

C# program to print the list of non-generic collections using LINQ

belongs to collection: C# LINQ Programs

0

C# program to print the list of non-generic collections using LINQ

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

//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+"#########");
        }
    }
}

Output:

##########System.Diagnostics.ProcessThreadCollection#########
##########System.ComponentModel.WeakHashtable#########
##########System.Collections.Concurrent.BlockingCollection`1+<GetConsumingEnumerable>d__0#########
##########System.Collections.Generic.SortedSet`1+<Reverse>d__12#########
##########System.Diagnostics.ListenerElementsCollection#########
##########System.Diagnostics.SharedListenerElementsCollection#########
##########System.Diagnostics.SourceElementsCollection#########
##########System.Collections.Specialized.ListDictionary+NodeKeyValueCollection#########
##########System.Collections.Specialized.OrderedDictionary+OrderedDictionaryKeyV
alueCollection#########
##########System.Collections.Specialized.StringDictionaryWithComparer#########
##########System.Net.ProxyScriptChain#########
##########System.Net.DirectProxy#########
##########System.Net.StaticProxy#########
##########System.Configuration.ConfigXmlAttribute#########
##########System.Configuration.ConfigXmlCDataSection#########
##########System.Configuration.ConfigXmlComment#########
##########System.Configuration.ConfigXmlElement#########
##########System.Configuration.ConfigXmlSignificantWhitespace#########
##########System.Configuration.ConfigXmlText#########
##########System.Configuration.ConfigXmlWhitespace#########
##########System.Configuration.ReadOnlyNameValueCollection#########
Press any key to continue . . .

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

total answers (1)

C# LINQ Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to print the employees whose id is grea... >>
<< C# program to generate numbers that are multiples ...