zoukankan      html  css  js  c++  java
  • 反射

    反射是为了程序在运行时程序能获取到一些关于程序集(assembly),class,method,property的一些信息的 这样的机制

    反射相当于一种进程,这种进程可以修改自己机构和行为的一种能力.

    string s = "Hello Reflection";
                Type t = s.GetType();
                Console.WriteLine(t.FullName);
                Type t2 = Type.GetType("system.string", false, true);
                Console.WriteLine(t2.FullName);
                Type t3 = typeof(string);
                Console.WriteLine(t3.FullName);
                Console.ReadLine();
            static void Main(string[] args)
            {
                string s = "Hello Reflection";
                Type t = s.GetType();
                Console.WriteLine(t.FullName);
                Type t2 = Type.GetType("system.string", false, true);
                Console.WriteLine(t2.FullName);
                Type t3 = typeof(string);
                Console.WriteLine(t3.FullName);
                //GetMothods(t3);
                Console.WriteLine(t3.GetMethod("Copy"));
                Console.ReadLine();
    
            }
            public static void GetMothods(Type t)
            {
                MethodInfo[] mti = t.GetMethods();
                foreach (MethodInfo m in mti)
                {
                    Console.WriteLine("type:{0}", m.Name);
                }
            }

    //getmethod getmethods gettype getproperty 都是反射

  • 相关阅读:
    Anniversary party
    1358. 分割树
    我在 impress.js 中学到的小套路
    我对 impress.js 源码的理解
    CSS transition 过渡 详解
    CSS 2D转换 matrix() 详解
    JS 动画基础
    JS 瀑布流布局
    JS 下拉菜单
    JS Resizable Panel 练习
  • 原文地址:https://www.cnblogs.com/handsomer/p/4554087.html
Copyright © 2011-2022 走看看