摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Reflection;namespace ReflectionExam{ class Pepper { public string name; public string Name { get { return name; } set { name = value; } } private string color; public string Color { get { return color; } s 阅读全文
posted @ 2013-03-28 18:57 Predator 阅读(204) 评论(0) 推荐(0) 编辑
摘要: // System.Reflection.Assembly[]assemblys=AppDomain.CurrentDomain.GetAssemblies(); //foreach (var item in assemblys) //{ // Console.Write(item.GetName()); //} // Console.WriteLine("**********应用程序集************"); // //Assembly assembly=Assembly.Load("XXX.dll")//加载应用程序集 // Assembly 阅读全文
posted @ 2013-03-28 18:56 Predator 阅读(146) 评论(0) 推荐(0) 编辑
摘要: public static void DisplayString(params string[] strNames)//好像对于本例来说去掉params效果也一样,但是加上params后直接使用传递的参数列表 { foreach (var item in strNames) { Console.WriteLine(item.ToString()); } } public static void ParamsTest( string[] names) { for (int i = 0; i < names.Length;i++ ) { Console.WriteLine(names[i]) 阅读全文
posted @ 2013-03-28 18:53 Predator 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 鄙人初学反射特性动手练习了一下:分三步:首先自定义MeetingRecordAttribute类; 然后在其它的类中引用使用该特性; 最后访问该特性的基本信息;(-)具体的源代码如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConAttribute{ //AllowMultiple=true表示这个特性可以多次应用到同一应用程序元素上,Interited=true表示子类可以具有这个特性 [AttributeUsageAttribute(Attribu 阅读全文
posted @ 2013-03-28 18:45 Predator 阅读(156) 评论(0) 推荐(0) 编辑
摘要: string className = System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName; //获取正在运行方法所在类的类型名字Console.WriteLine(className);//输出ConAttribute.Program 阅读全文
posted @ 2013-03-28 15:32 Predator 阅读(138) 评论(0) 推荐(0) 编辑