This one got by me!
Apparently in C# 2.0 with the introduction of nullable types (Nullable<T>), C# grew an operator:
int? x = null;
int? y = x ?? 0;
?? is a binary operator that returns the left value if it is not null, otherwise the right value.
Wacky!
I can only thing of a single use for this:
String errorMessage404 = localizedString("error404", "es") ?? "Error 404: File not found."
I'm sure there must be some other uses, but none seem obvious.
Quote from: Joex86] link=topic=16128.msg162518#msg162518 date=1165969018]
I can only thing of a single use for this:
String errorMessage404 = localizedString("error404", "es") ?? "Error 404: File not found."
I'm sure there must be some other uses, but none seem obvious.
......
Quote from: MyndFyre[vL] on December 12, 2006, 08:00 PM
Quote from: Joex86] link=topic=16128.msg162518#msg162518 date=1165969018]
I can only thing of a single use for this:
String errorMessage404 = localizedString("error404", "es") ?? "Error 404: File not found."
I'm sure there must be some other uses, but none seem obvious.
......
Exactly what I was thinking....
So, what did I miss?
Quote from: Joex86] link=topic=16128.msg162554#msg162554 date=1166026656]
So, what did I miss?
Indeed, heRo, what did he miss?
Quote from: MyndFyre[vL] on December 13, 2006, 05:13 PM
Quote from: Joex86] link=topic=16128.msg162554#msg162554 date=1166026656]
So, what did I miss?
Indeed, heRo, what did he miss?
I never said he missed anything...
I love you Myndfyre.
I love myself.
just to save you from having to type an extra colon and a null in your code? seems slightly redundant from just ?
Quote from: Imperceptus on December 15, 2006, 01:18 PM
just to save you from having to type an extra colon and a null in your code? seems slightly redundant from just ?
string val = x ?? "null x";
string val = x == null ? "null x" : x;
I think the first is much clearer in intent.