harriyott.com

Nullable int in C#

I was looking at somebody's code today (I've no idea whose), and I came across a line something like the following:

int? thing = GetSomethingOrOther();

Looks okay. Yup. Oh, hang on, what's that? There's a question mark after the int! How could that compile? Maybe it's an encoding issue or something. No, seems like a real one. Better google it. Ah, it's a nullable int. Fancy that. Well I never.
27 September 2007