.net - Given simple type T, get array type T[] -
this question has answer here:
how can type of array of type t
given t
?
linqpad-friendly snippet below:
void main() { type t = typeof(string); type tarray = getarraytype(t); tarray.dump(); // system.string[] } type getarraytype(type t) { ////this cheating !! //return typeof(string[]); }
this trick:
type.makearraytype()
eg:
int = 123; type atype = a.gettype(); type aarraytype = atype.makearraytype(); // aarraytype.fullname = "system.int32[]"