.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[]" 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

java - How to create Table using Apache PDFBox -

mpi - Why is MPI_Bsend not returning error even when the buffer is insufficient to accommodate all the messages -