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);
}
VulpesPosted Jan 23, 2013, 5:55 PM
So, try it like this:
boneheadPosted Jan 23, 2013, 7:36 PM
VulpesPosted Jan 23, 2013, 7:30 PM
boneheadPosted Jan 23, 2013, 6:25 PM
boneheadPosted Jan 23, 2013, 6:19 PM