This has me pretty stumped. Maybe I'm too tired right now.
Rectangle rectangle = new Rectangle(0, 0, image.Width, image.Height);
Rectangle cropArea = inputArea == null ? rectangle : inputArea.Value;
if (inputArea == null)
cropArea = rectangle;
inputArea is a nullable Rectangle, which in my particular case is null.
The first two statements yields a cropArea initialized to 0. The second, however, yields the correct cropArea based on the image width and height. Have I misunderstood anything with the conditional operator? It seems it does not return rectangle when inputArea = null? Is there any quirks when working with value types?
EDIT: Alright, I should have tried this first: restarted VS. It seems the debugger lied to me, or something. Anyway, works now. Thanks.
That seems like a nasty bug in Visual Studio debug mode which is fooling you:
Now F10 to step over this line and you get:
On the console correct values are printed.
WTF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With