C #反射查看程序集中的类和方法 ★说明: 1
在v s2005 中,新建控制台项目:TestReflection 2
右键“解决方案”,点击“添加”→“新建项目”,选择“类库”,将类库命名为 TestClassLibrary 3
将类库 TestClassLibrary 的生成--输出路径设置到 TestReflection 的bin\debu g\目录下
解决方案下的文件如截图: 4
在类库TestClassLibrary 项目中,删除默认的类Class1,添加3个类,分别是:OperatorClass,Test1, Test2
这三个类的代码如下: ★类OperatorClass 源代码: using System; using System
Collections
Generic; using System
Text; namespace TestClassLibrary { /// /// 基本运算操作类 /// public class OperatorClass { /// /// 加法 /// /// /// /// public static int Add(int x, int y) { return x + y; } /// /// 减法 /// /// /// /// public static int Subtract(int x, int y) { return x - y; } /// /// 乘法 /// /// /// /// public int Mulitiple(int x, int y) { return x * y; } /// /// 除法 /// /// /// /// public int Divide(int x, int y) { if (y == 0) { Console
WriteLine("除法操作时,除数不能