c# - How do I recognize a System.Type instance representing SZ-Array? -


clr uses distinct system.type instances represent sz-arrays (single-dimensional, zero-based, aka vectors) , non-zero-based arrays (even if single-dimensional). need function takes instance of system.type , recognizes if represents sz-array. able check rank using getarrayrank() method, not know how check zero-based. please me?

using system;  class program {     static void main()     {         var type1 = typeof (int[]);         var type2 = array.createinstance(typeof (int), new[] {1}, new[] {1}).gettype();          console.writeline(type1 == type2); // false          console.writeline(issingledimensionalzerobasedarray(type1));  // true         console.writeline(issingledimensionalzerobasedarray(type2)); //  should false     }      static bool issingledimensionalzerobasedarray(type type)     {         // how fix implementation?         return type != null && type.isarray && type.getarrayrank() == 1;     } } 

static bool issingledimensionalzerobasedarray(type type) {     return type != null && type.isarray && type == type.getelementtype().makearraytype(); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -