如何通過反射判斷一個類所有成員是否使用了特性
uj5u.com熱心網友回復:
GetProperty后,我記得有個GetCustomAttributes?uj5u.com熱心網友回復:
對是這個,
,謝謝。。。。。。
uj5u.com熱心網友回復:
如果要判斷是否有指定特性的話可以這么寫比如,
var type = typeof(class);
var propertyInfos = type.GetProperties();
foreache(var p in propertyInfos)
{
if(p.IsDefined(typeof(CustomeAttribute), true))
{
.......................
}
}
手寫的可能有拼寫錯誤!
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/86347.html
標籤:C#
