Bor*_*ens 5 .net c# reflection
我有一个类型SearchBag,它包含一堆字符串和可空的整数,用于传递搜索值.我需要一种方法来检查搜索包是否包含任何值.
我目前正在尝试这样做:
public bool HasValues()
{
return GetType().GetProperties().Any(p => p.GetValue(this, null) != null);
}
Run Code Online (Sandbox Code Playgroud)
但是想知道是否有更好的方法.
| 归档时间: |
|
| 查看次数: |
2933 次 |
| 最近记录: |