在Reflection中,PropertyInfo和FieldInfo有什么区别?
来源:互联网 发布:笑道人捏脸数据 编辑:程序博客网 时间:2024/05/01 15:53
public class Test { public int A; private int _b; public int B { get { return _b; } } } A就是Field,B就是Property。那么什么是FieldInfo,什么是PropertyInfo应该很显然了。不过呢,二者的确很相似也应该很相似(A,B不也很相似吗):都继承自MemberInfo。 Public Sub CopyEntity(ByRef DestObj As Object, ByRef SrcObj As Object) Dim type As Type = SrcObj.GetType() Dim p As PropertyInfo() = type.GetProperties() Dim i As Integer For i = 0 To p.Length - 1 p(i).SetValue(DestObj, p(i).GetValue(SrcObj, Nothing), Nothing) Next End Sub Private Function GetCriteria(ByVal fieldName As String) As AddrBookCriteria Dim criteria As AddrBookCriteria = New AddrBookCriteria() criteria.COMPCODE = Me.txtCode.Text.Trim Dim type As Type = criteria.GetType() Dim field As System.Reflection.FieldInfo = type.GetField(fieldName) If field Is Nothing Then Throw New Exception(String.Format("There is not this type[{0}] in the AddrBook", fieldName)) End If field.SetValue(criteria, True) Return criteria End Function
- 在Reflection中,PropertyInfo和FieldInfo有什么区别?
- 反射:PropertyInfo、FieldInfo和MemberInfo的区别
- FieldInfo和PropertyInfo简析
- C++中“->”和“.”在使用中有什么区别呢
- 在.net中,int和int?有什么区别?
- 在oracle中varchar和varchar2有什么区别?
- 在java中 i++和++i有什么区别
- 请问在JAVA中Map和HashMap有什么区别?
- 在oracle中varchar和varchar2有什么区别?
- const在c和c++中有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在 JavaScript 中 prototype 和 __proto__ 有什么区别
- 在linux中,rpm和yum有什么区别
- asp.net中执行exe应用程序2008-07-03 15:53在asp.net中执行应用程序有两种方法:1、调用win32函数ShellExecute。2、用.NET Framework中的Process类。下面我分别用这两种方法执行Windows中的
- 应聘外企要在英文简历上下功夫,看老外的简历
- MySQL权威指南读书笔记(一) (转载)
- Halcon软件使用心得
- MySQL权威指南读书笔记(二)(转载)
- 在Reflection中,PropertyInfo和FieldInfo有什么区别?
- Java程序最容易犯的21种错误实例分析
- Linux文件查找命令find,xargs详述
- MySQL权威指南读书笔记(三) (转载)
- 只要能言之有理,持之有据,则可立于讲台
- 大连软件业转型:吸引人才掌控产业链上游
- 建站指南
- 定制Row的不同颜色
- 学习GDI+画出汽车行进路线c#(winform)