eba
eba

Reputation: 673

C# reflection getting nullable type

i have class, with fields of double? type. with reflection i get fields

Parameters cl = new Parameters();
FieldInfo[] fi = cl.GetType().GetFields((BindingFlags.NonPublic | BindingFlags.Instance));

now, i want get fields, only with double? type, gow can i get this type, to compare with fields from fi?

smth like:

if(fi[0].FieldType == (double?).GetType()){...}

Upvotes: 0

Views: 844

Answers (1)

Andrey
Andrey

Reputation: 60065

if(fi[0].FieldType == typeof(Nullable<double>)){...}

or

if(fi[0].FieldType == typeof(double?)){...}

Upvotes: 1

Related Questions