Quantcast
Channel: Digital Transition » .NET
Viewing all articles
Browse latest Browse all 10

Reflection GetValue of bool? is bool

$
0
0
After several hours looking for a bug, I finally found it. This is the code that housed the “bug”. PropertyInfo info = obj.GetType().GetProperty("SomeProperty"); object value = info.GetValue(obj, null); if (value.GetType() == typeof(bool?)) { //Some code } else if (value.GetType() == typeof(int?)) { //Some other code } The property “SomeProperty” is a nullable type (either string, [...]

Viewing all articles
Browse latest Browse all 10

Trending Articles