Getting invalid cast exception, when casting from string to int32[]. What's the correct approach to casting below.
Thanks.
int[] ii = ReadField
static T ReadField
{
Type u = typeof(T);
string[] foundValues = "4,9".Split(',');
Array a = Array.CreateInstance(u, foundValues.Lenght);
for (int i =0; i < foundValues.Lenght, i++)
a.SetValue(Convert.ChangeType(foundValues[i], u), i); <== Incorrect cast string to int32[]
return ?? (T)Convert.ChangeType(a, u);
}

VulpesRank #55 · 29.2K reputationPosted Jan 23, 2013, 12:55 PM EST
So, try it like this:
bonehead7 reputationPosted Jan 23, 2013, 1:19 PM EST
bonehead7 reputationPosted Jan 23, 2013, 1:25 PM EST
VulpesRank #55 · 29.2K reputationPosted Jan 23, 2013, 2:30 PM EST
bonehead7 reputationPosted Jan 23, 2013, 2:36 PM EST