反射的一个实例
2007-07-29 21:22
197 查看
下面是使用静态方法 GetType-- 从 Object 基类派生的所有类型都继承该方法 --
获取变量类型的简单反射示例:
C#
输出为:
System.Int32
此示例使用反射获取已加载的程序集的完整名称:
获取变量类型的简单反射示例:
C#
// Using GetType to obtain type information: int i = 42; System.Type type = i.GetType(); System.Console.WriteLine(type);
输出为:
System.Int32
此示例使用反射获取已加载的程序集的完整名称:
// Using Reflection to get information from an Assembly: System.Reflection.Assembly o = System.Reflection.Assembly.Load("mscorlib.dll"); System.Console.WriteLine(o.GetName());
相关文章推荐
- 反射-实例化一个未知的类(使用System.AppDomain类)
- 一个反射方法应用实例
- 笔试题12:如何利用反射实例化一个类(源码)
- 一个反射将对象转化为sql语句的实例
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- Java反射代码--01.通过类名称加载一个类并且获取当前类实例
- 反射-实例化一个未知的类(使用System.AppDomain类)
- C#反射方法来处理每个子窗体只保留一个实例
- Java反射之通过反射获取一个对象的方法信息(实例代码)
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- 反射机制的一个小实例
- 关于Java反射机制的一个实例
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- 一个反射的实例
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- C++ 中实现(模拟)反射,及一个实例
- JAVA 反射获取一个实例的所有字段值