dimanche 7 juillet 2019

How do you get the Element Type of an Empty Array in C#?

Int32[] myArray = new Int32[0];

//Somewhere else in code: 
Type t = myArray.GetType();

//t == Int32[]
//element type of t == ???

How do I find out the element type that t was created to store.

The only example I've found works on arrays that aren't empty, where you simply do myArray[i].GetType(). So what do you do for array length 0?





Aucun commentaire:

Enregistrer un commentaire