3
Reply

C# Compiler Detecting Overflow?

Daniel Roberts

Daniel Roberts

Nov 28 2008 11:52 PM
2.4k

I am passing 0xffff0000 to a DirectX function that takes an int and interprets the int as a color (fully transparent red). The C# compiler says this is an error because it is auto-converting 0xffff0000 to a uint and saying it can't convert the value to an int (which is what the function takes). Is the C# compiler disallowing overflow? This wouldn't be a problem in C/C++ because the function looks at the byte content of the parameter anyway. Is there a solution to this?

By the way, is there a good resource (web or book) where I can find gory C# details like this? Something like Stroustrup's C++ book?

Thanks


Answers (3)