[英]Using reflection, how do I detect properties that have setters?
我有這個代碼循環一個對象,並通過反射獲取其所有屬性:
foreach (var propertyInfo in typeof(TBase).GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
var oldValue = propertyInfo.GetValue(oldVersion, null);
}
如何檢查只查看有“設置”的屬性? (我想忽略只讀值 - 只是“獲取”。)
propertyInfo.GetSetMethod() != null
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.