zoukankan      html  css  js  c++  java
  • 反射的用法1

    反射用到的几个类:

    1.代表程序集:System.Reflection.Assembly

    2.代表类与结构:System.Reflection.Type

    3.代表方法:System.Reflection.MethodInfo

    4.代表字段:System.Reflection.FieldInfo

    5.代表方法参数:System.Reflection.ParameterInfo

    例子:

    using System;
    using System.Reflection;

    namespace ReflectionConsoleApplication1
    {
        
    class Program
        {
            
    static void Main(string[] args)
            {
                Assembly assembly 
    = Assembly.GetExecutingAssembly();
                
    foreach(Type type in assembly.GetTypes())
                {
                    Console.WriteLine (
    "Class:"+type.ToString());
                    
    foreach (MethodInfo method in type.GetMethods())
                    {
                        Console.WriteLine(
    "method:" + method.ToString());
                        
    foreach (ParameterInfo param in method.GetParameters())
                            Console.WriteLine(
    "Parameter:"+param.ToString ());
                    }
                }
                Console.ReadLine();
            }
        }
    }
  • 相关阅读:
    免费申请域名
    分享学习linux网站
    二分法
    node 解决存储xss风险报告
    cf987f AND Graph
    loj2587 「APIO2018」铁人两项
    luogu3830 [SHOI2012]随机树
    luogu3343 [ZJOI2015]地震后的幻想乡
    bzoj2560 串珠子
    luogu3317 [SDOI2014]重建
  • 原文地址:https://www.cnblogs.com/ringwang/p/1897051.html
Copyright © 2011-2022 走看看