• 反射DLL示例 C#


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Reflection;
    
    namespace Dachie
    {
        class Program
        {
            static void Main(string[] args)
            {
                Assembly a = Assembly.LoadFrom(@"DLL文件绝对路径");
                Type[] mytypes = a.GetTypes();
                BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
                    BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
    
                foreach (Type t in mytypes)
                {
                    MethodInfo[] mi = t.GetMethods(flags);
                    Object obj = Activator.CreateInstance(t);
    
                    foreach (MethodInfo m in mi)
                    {
                        m.Invoke(obj, null);
                    }
                }
            }
        }
    }
  • 相关阅读:
    蚂蚁
    N的阶乘
    最小公倍数LCM
    最大公约数GCD
    Truck History(卡车历史)
    亲戚
    [SDOI2011]打地鼠
    连续自然数和
    P4250 [SCOI2015]小凸想跑步
    P4048 【[JSOI2010]冷冻波】
  • 原文地址:https://www.cnblogs.com/dachie/p/1734502.html
Copyright © 2020-2023  润新知