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?
FYI: I did the following and it works fine, but wow... it uses string conversion and is super ugly. There's got to be a better way:
Type t = myArray.GetType();
string strT = t.ToString();
string strArrayBase = strT.Substring(0, strT.Length - 2);
Type elementType = Type.GetType(strArrayBase);