《2020年优秀范文 NET学习心得》由会员分享,可在线阅读,更多相关《2020年优秀范文 NET学习心得(3页珍藏版)》请在金锄头文库上搜索。
1、优秀范文 net学习心得 优秀范文:.学习心得是一篇好的范文,感觉写的不错,希望对您有帮助,希望大家能有所收获。 1.:反射是.中的重要机制,通过反射可以在运行时获得.中每,包括类、结构、委托和枚举的成员,包括方法、属性、事件,以及构造函数等。有了反射,既可以对每一个类型了如指掌。 下面来演示一下反射的实例 (1)新建一个类库。在解决方案上单击右键选择“新建项目”,在弹出来的框中选择“类库”,在下面名字栏中输入classlib。然后删除class1类,新添加一个类“classperson”,添加如下代码 namespace classlib public class classperson p
2、ublic classperson():this(null) public classperson(string strname) name = strname; private string name; private string sex; private int age; public string name get return name; set name = value; public string sex get return sex; set sex = value; public int age get return age; set age = value; public
3、void sayhello() if (null=name) console.writeline(hello world); else console.writeline(hello, + name); 添加完之后编译生成一下,就会在这个类库项目中的bindebug中有一个classlib.dll文件。然后添加一个控制台应用程序。引入system.reflaction的命名空间。添加的代码 using system; using system.collections.generic; using system.linq; using system.text; using system.refl
4、ection;/添加反射的命名空间 namespace consoleapplication4 public class program static void main(string args) console.writeline(列出程序集中的所有类型); assembly ass = assembly.loadfrom(classlib.dll); type mytype = ass.gettypes(); type classperson = null; foreach (type p in mytype) console.writeline(p.name); if (p.name=classperson) 以上就是优秀范文:.学习心得的范文全部内容,主要描述反射、一个、添加、项目、类型、空间、可以、代码,()收藏。 模板,内容仅供参考