System.Type类

System.Type类
——摘自 C#高级编程(第3版)
引用:
Type t = typeof(double)
Type t = d.GetType();
Type t = Type.GetType("System.Double");
屬性:

    

  

Name

数据类型名

FullName

数据类型的完全限定名(包括命名空间名)

Namespace

定义数据类型的命名空间名

   

返回对应的Type引用

BaseType

这个Type的直接基本类型

UnderlyingSystemType

这个Type .NET 运行库中映射的类型 (某些.NET基类实际上映射由IL识别的特定预定义类型)

其它一些Boolean 属性表示这个类型是一个类、还是一个枚举等。这些属性包括IsAbstract、IsArray、IsClass、IsEnum、IsInterface、IsPointer、IsPrimitive(一种预定义的基本数据类型)、 IsPublic、IsSealed和IsValueType

方法:用于获取对应数据类型的成员信息:构造函数、属性、方法和事件等。

返回的对象类型

方法 (名称为复数形式的方法返回一个数组)

ConstructorInfo

GetConstructor(), GetConstructors()

EventInfo

GetEvent(), GetEvents()

FieldInfo

GetField(), GetFields()

InterfaceInfo

GetInterface(), GetInterfaces()

MemberInfo

GetMember(), GetMembers()

MethodInfo

GetMethod(), GetMethods()

PropertyInfo

GetProperty(), GetProperties()

 

一個小例子:

 

ExpandedBlockStart.gif 代码
        Type t  =   typeof (String);

        MethodInfo substr 
=  t.GetMethod( " Substring "
            
new  Type[] {  typeof ( int ),  typeof ( int ) });

        Object result 
=  
            substr.Invoke(
" Hello, World! " new  Object[] {  7 5  });
        Console.WriteLine(
" {0} returned \ " { 1 }\ " . " , substr, result);
輸出:System.String Substring(Int32, Int32) returned 
" World " .


转载于:https://www.cnblogs.com/peipei2009/archive/2010/06/09/1754590.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值