zoukankan      html  css  js  c++  java
  • 反射原理的简单例子

    源代码:CLib.rar
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace CLibConsole
    {
        
    public interface ITest
        
    {
            
    void SysTest();
        }

    }



    using System;
    using System.Collections.Generic;
    using System.Text;
    using CLibConsole;

    namespace CLibConsole
    {
        
    public class Test : ITest
        
    {
            
    public void SysTest()
            
    {
                System.Console.WriteLine(
    "Hello Reflection");
            }

        }

    }


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

    namespace CLibConsole
    {
        
    class Program
        
    {
            
    static void Main(string[] args)
            
    {
                
    //Assembly ass = System.Reflection.Assembly.LoadFrom("CLib.dll");
                
    //Type type = ass.GetType("CLibConsole.Test");
                
    //Type type = System.Activator.CreateInstanceFrom("CLib.dll", "CLibConsole.Test").GetType();

                ITest test 
    = (ITest)System.Activator.CreateInstance("CLib""CLibConsole.Test").Unwrap();
                test.SysTest();
            }

        }

    }


  • 相关阅读:
    commando VM安装
    Pocscan搭建详解
    Windows-RW-LinuxFS
    Festival
    ffmpeg-metadata
    FFmpeg-Screen-Recording
    ffmpeg-map
    ffmpeg-utils
    Linux-Fcitx5
    ffmpeg-volumedetect
  • 原文地址:https://www.cnblogs.com/adam/p/977829.html
Copyright © 2011-2022 走看看