Cast not valid issue

Explore, browse and analyze .NET assemblies

Moderators: Luke Jefferson, Clive Tong, nick.maidment

Cast not valid issue

Postby alehandro » Sat Jan 29, 2011 12:00 pm

Hi, in some cases a cast is required for uint (maybe some other basic types)

in following example

objArray2 = p3 as object[];
string str = objArray2[0] as string;
string str2 = objArray2[1] as string;
DateTime time = (DateTime) objArray2[2];
uint num2 = (uint) objArray2[3];

the last line throws an exception:

---------------------------
Exception
---------------------------
Specified cast is not valid.

at ...........[skipped]
---------------------------
OK
---------------------------

not sure whats the right was to handle it.....
I've changed last line into

uint num2 = Convert.ToUInt32(objArray2[3]);
alehandro
 
Posts: 35
Joined: Tue Nov 16, 2010 12:08 am

Return to .NET Reflector 7 EAP

Who is online

Users browsing this forum: No registered users and 0 guests