naw*_*fal 8 .net accessor propertyinfo getter-setter .net-4.5
.Net 4.5将PropertyInfo.GetMethod作为PropertyInfo类的属性.它在做什么不同于PropertyInfo.GetGetMethod方法吗?文档页面几乎为空白.我能找到的唯一区别是GetGetMethod默认情况下仅返回公共getter,而GetMethod返回甚至非公共getter(同样通过它实现GetGetMethod(true)).
类似地,.NET 4.5中有GetSetMethod方法和SetMethod属性.它为什么在.NET中引入?
Car*_*ten 15
没有区别.该物业GetMethod要求GetGetMethod获得吸气剂.1这是ILSpy告诉我的有关属性实现的内容:
// System.Reflection.PropertyInfo
[__DynamicallyInvokable]
public virtual MethodInfo GetMethod
{
[__DynamicallyInvokable, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
get
{
return this.GetGetMethod(true);
}
}
Run Code Online (Sandbox Code Playgroud)
该属性GetMethod更易于使用,因为它与参数无关.
1 从来没有想过我只用一句话就可以使用这么多次!
| 归档时间: |
|
| 查看次数: |
1814 次 |
| 最近记录: |