tags:

views:

67

answers:

5

Hello,

I have a function that basically does:

internal static short GetPresentYear()
{
    return Convert.ToInt16(DateTime.Now.Year - 1);
}

Now when I try using the function, the debugger shows that I'm getting 0x07d9 instead of the year 2008...

What am I doing wrong here? How do I make it return 2008?

Thanks.

Edit: I know I can use int instead of short but the database is designed to store smallint and so I'm forced to use a short.

+3  A: 

That does return 2008 for me. Is that your actual code?

For info, 0x07d9 is simply 2009 in hex. You can toggle this in the debugger by hovering over the value and checking / unchecking "Hexadecimal Display".

Marc Gravell
That was it. The hexadecimal display got all confusing. Thanks.
Jim
+3  A: 

Have you got Hexadecimal Display turned on in your output window?

Right click over the output window and it's an option on the context menu.

ChrisF
A: 

Do you have the debugger set to display hexa values? 0x07d9 is hexa for 2009. Go over the watch window, right click and check that 'hexadecimal display' is not selected.

rslite
A: 

i got 2008. not 0x07d9(its Hexadecimal Display)

anishmarokey
+3  A: 

Hexadecimal 0x07d9 is 2009 decimal, so everything is correct.

Right-click on the locals / watch window and un-check the hexadecimal setting.

Magnus Johansson