I have a property defined as:
public bool[] _array { get; set; }
public bool?[] _null_array { get; set; }
I followed the instructions in How do I determine the underlying type of an array
foreach (var _property in typeof(T).GetProperties())
{
var _propertyType = _property.PropertyType;
var _propertyName = _property.Name;
var CheckArray = _propertyType.IsArray;
var UType = _propertyType.GetElementType().Name;
....
}
The results for UType is:
_array => "Boolean"
_null_array => "Nullable`1"
How do I get the type of an array of nullable primitive ?
Thanks.
You already have it. The array element type is
bool?akaNullable<bool>akaNullable``1(only one backtick, blame markdown) with generic argumentbool. If you're afterbool, then you'll wantNullable.GetUnderlyingTypeon the element type; this returnsnullfor things that aren'tNullable<T>, so consider: