标签:blog http io ar for sp 数据 on log
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)
{
//System.Type类
//=========================获取指向任何给定的类型的Type引用有3中常用模式
//第一种:
Type t1 = typeof(int);
//第二种:
bool d = true;
Type t2 = d.GetType();
//第三种:
Type t3 = Type.GetType("System.Double");
//=========================Type属性
Console.WriteLine(t1.Name); //Int32
Console.WriteLine(t1.Namespace); //System
Console.WriteLine(t1.FullName); //System.Int32
//进一步获取基层的Type
Console.WriteLine(t1.BaseType.FullName); //System.TypeValue
Console.WriteLine(t2.UnderlyingSystemType.FullName); //System.Boolean(该type在.net运行库映射到的类型)
//判断Type的类型
Console.WriteLine(t1.IsPrimitive);//True(是否是预定义类型)
Console.WriteLine(t1.IsClass);//Flase(是否是类)
//=========================Type方法
//获取该数据类型的成员信息
//MemberInfo[] mi = t1.GetMembers(BindingFlags.Instance | BindingFlags.Public);//筛选出公共成员
MemberInfo[] mi = t1.GetMembers();//获取所有的成员
foreach (var item in mi)
{
// 声明类型 描述成员的类型(方法,字段,等) 成员的名称
Console.WriteLine(item.DeclaringType + "\t" + item.MemberType + "\t" + item.Name);
}
Console.ReadKey();
}
}
}
本文出自 “程序猿的家--Hunter” 博客,请务必保留此出处http://962410314.blog.51cto.com/7563109/1569451
标签:blog http io ar for sp 数据 on log
原文地址:http://962410314.blog.51cto.com/7563109/1569451