C#中基于System.Type的反射

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

namespace Reflection
{
    class Program
    {
        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);
          //  GetMehtods(t);

            Console.WriteLine("Join method:{0}",t.GetMethod("Copy"));

            GetMehtods(t,BindingFlags.Public|BindingFlags.Instance);

            //GetFields().GetProperites()
            Console.ReadLine();
        }
        public static void GetMehtods(Type t,BindingFlags f)
        {

            MethodInfo[] mi = t.GetMethods(f);
            foreach (MethodInfo m in mi)
            {
                Console.WriteLine("{0}",m.Name);
            }
        }
    }
}
时间: 2024-08-29 21:57:07

C#中基于System.Type的反射的相关文章

反射,System.Type类

http://m.blog.csdn.net/blog/woddle/40623333 两个现实中的例子:1.B超:大家体检的时候大概都做过B超吧,B超可以透过肚皮探测到你内脏的生理情况.这是如何做到的呢?B超是B型超声波,它可以透过肚皮通过向你体内发射B型超声波,当超声波遇到内脏壁的时候就会产生一定的“回音”反射,然后把“回音”进行处理就可以显示出内脏的情况了(我不是医生也不是声学专家,不知说得是否准确^_^).2.地球内部结构:地球的内部结构大体可以分为三层:地壳.地幔和地核.地壳是固体,地

System.Type.cs

ylbtech-System.Type.cs 1.返回顶部 1. #region 程序集 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll #endregion using System.Diag

【转】Power System 中基于 VIOS 的虚拟以太网实现

基于 VIOS 的虚拟以太网适配器的工作原理和配置实现 本文对 Power 系统中基于 VIOS 的虚拟以太网适配器(Virtual Ethernet Adapter)的工作原理.基本配置选项和配置步骤进行了讲解,并介绍了两种常用的 High Availability 的配置场景.Power System 的系统工程师可以通过本文了解虚拟以太网适配器的配置方法,软件工程师则可以学习到虚拟以太网适配器的工作原理. PowerVM 中相关概念简介 Power System 通过 PowerVM 软件

System.Type反射(1/3)

通过System.Type,我们可以获取某个类的全名.命名空间.属性等信息. 实验代码: static void Main(string[] args) { //System.Type string s = "hello refelction"; Type t = s.GetType(); //方法一 Console.WriteLine(t.FullName); Type t2 = Type.GetType("system.String", false, true)

Type.MakeGenericType 方法 (Type[]) 泛型反射

替代由当前泛型类型定义的类型参数组成的类型数组的元素,并返回表示结果构造类型的 Type 对象. 命名空间:   System程序集:  mscorlib(mscorlib.dll 中) public virtual Type MakeGenericType( params Type[] typeArguments ) 参数typeArguments将代替当前泛型类型的类型参数的类型数组. 返回值Type: System.TypeType 表示的构造类型通过以下方式形成:用 typeArgume

初解,Scala语言中基于Actor的并发编程的机制,并展示了在Spark中基于Scala语言的Actor而产生的消息驱动框架Akka的使用,

Scala深入浅出实战中级--进阶经典(第66讲:Scala并发编程实战初体验及其在Spark源码中应用解析)内容介绍和视频链接 2015-07-24 DT大数据梦工厂 从明天起,做一个勤奋的人 看视频.下视频,分享视频 DT大数据梦工厂-Scala深入浅出实战中级--进阶经典:第66讲:Scala并发编程实战初体验及其在Spark源码中的应用解析 本期视频通过代码实战详解了Java语言基于加锁的并发编程模型的弊端以及Scala语言中基于Actor的并发编程的机制,并展示了在Spark中基于Sc

python中基于descriptor的一些概念(下)

@python中基于descriptor的一些概念(下) 3. Descriptor介绍 3.1 Descriptor代码示例 3.2 定义 3.3 Descriptor Protocol(协议) 3.4 Descriptor调用方法 4. 基于Descriptor实现的功能 4.1 property 4.2 函数和方法,绑定与非绑定 4.3 super 5. 结尾 3. Descriptor介绍 3.1 Descriptor代码示例 class RevealAccess(object):   

类库探源——System.Type

一.MSDN 描述 Type 类:表示类型声明:类类型.接口类型.数组类型.值类型.枚举类型.类型参数.泛型类型定义.以及开放或封闭构造的泛型类型. 命名空间: System 程序集:mscorlib.dll 继承关系: 从上面的继承关系能看出,Type和反射有关系,的确,引用MSDN上的话Type 为 System.Relection 功能的根也是访问元数组的主要方式. 二.获取 Type 的几种方式: 1. typeof 运算符 1 var type1 = typeof(TypeName);

System.Type类

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {