console app - uint exit code?

stumper66

Newcomer
Joined
Jul 11, 2006
Messages
16
Location
Seattle, WA
I have a console application. I would like to use uint for the exit code, eg. Environment.Exitcode = 0x80070005

Is there a method for returning unsigned integers or long integers? The reason is, I'm catching exceptions and want to return the native windows error code, such as System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
 
The Main method is limited to returning an int or void - this is enforced by the runtime. Have you tried casting the unit to an int and then seeing what happens?
 
0x80070005 = 2,147,942,405.

Int.MaxValule returns: 2,147,483,647

As you can see, if I were to convert it to an Int, it would truncate the numbers, as MaxValue is 458,758 lower than my number.
 
PlausiblyDamp said cast not convert.
I.e.
uint x = 2147942405;
int y = (int)x;
Console.WriteLine("x:"+x.ToString());
Console.WriteLine("y:"+y.ToString());
which results in:
x:2147942405
y:-2147024891

Hope that helps,
 
Back
Top