stumper66 Posted May 19, 2009 Posted May 19, 2009 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)) Quote
Administrators PlausiblyDamp Posted May 20, 2009 Administrators Posted May 20, 2009 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
stumper66 Posted May 20, 2009 Author Posted May 20, 2009 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. Quote
forgottensoul Posted May 20, 2009 Posted May 20, 2009 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, Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.