samedi 25 mars 2017

How to differentiate the types: Int32[] & Int32[*]?

Given the following code:

var type1 = typeof(int[]); // Int32[]
var type2 = Array.CreateInstance(elementType: typeof(int),
                                 lengths: new [] {0},
                                 lowerBounds: new []{1}).GetType(); // Int32[*]

Given an array type (a type where .IsArray returns true), how can I reliably differenciate between those two kinds of array types?

Without using any hacky solutions preferably (like instantiating the type or looking for "*" in the name).





Aucun commentaire:

Enregistrer un commentaire