Linq and Reflection

This snippet will show how LINQ can be used with reflection to retrieve specific metadata about the type that match a specified search criterion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Linq_Tips
{
    class Program
    {
        static void Main(string[] args)
        {
            Assembly assembly = Assembly.Load("System.Data, Version=3.5.0.0, Culture=neutral, " + "PublicKeyToken= b77a5c561934e089");
            var Query = from type in assembly.GetTypes()
                        where type.IsClass
                        select type;
            foreach (var item in Query)
            {
                Console.WriteLine(item.Name);

            }
            Console.WriteLine("Press any key to exit ... ");
            Console.ReadKey();

        }
    }
} 

Linq and Reflection

Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads

CodeGuru