.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? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -