Author | Message | Time |
---|---|---|
Myndfyr | This one got by me! Apparently in C# 2.0 with the introduction of nullable types (Nullable<T>), C# grew an operator: [code] int? x = null; int? y = x ?? 0; [/code] ?? is a binary operator that returns the left value if it is not null, otherwise the right value. Wacky! | December 12, 2006, 8:29 AM |
JoeTheOdd | I can only thing of a single use for this: [tt]String errorMessage404 = localizedString("error404", "es") ?? "Error 404: File not found."[/tt] I'm sure there must be some other uses, but none seem obvious. | December 13, 2006, 12:16 AM |
Myndfyr | [quote author=Joe[x86] link=topic=16128.msg162518#msg162518 date=1165969018] I can only thing of a single use for this: [tt]String errorMessage404 = localizedString("error404", "es") ?? "Error 404: File not found."[/tt] I'm sure there must be some other uses, but none seem obvious. [/quote] ...... | December 13, 2006, 2:00 AM |
HeRo | [quote author=MyndFyre[vL] link=topic=16128.msg162522#msg162522 date=1165975207] [quote author=Joe[x86] link=topic=16128.msg162518#msg162518 date=1165969018] I can only thing of a single use for this: [tt]String errorMessage404 = localizedString("error404", "es") ?? "Error 404: File not found."[/tt] I'm sure there must be some other uses, but none seem obvious. [/quote] ...... [/quote] Exactly what I was thinking.... | December 13, 2006, 3:47 AM |
JoeTheOdd | So, what did I miss? | December 13, 2006, 4:17 PM |
Myndfyr | [quote author=Joe[x86] link=topic=16128.msg162554#msg162554 date=1166026656] So, what did I miss? [/quote] Indeed, heRo, what did he miss? | December 13, 2006, 11:13 PM |
HeRo | [quote author=MyndFyre[vL] link=topic=16128.msg162571#msg162571 date=1166051625] [quote author=Joe[x86] link=topic=16128.msg162554#msg162554 date=1166026656] So, what did I miss? [/quote] Indeed, heRo, what did he miss? [/quote] I never said he missed anything... | December 13, 2006, 11:49 PM |
Quarantine | I love you Myndfyre. | December 13, 2006, 11:50 PM |
Explicit[nK] | [quote author=Warrior link=topic=16128.msg162575#msg162575 date=1166053808] I love you Myndfyre. [/quote] Me, too. | December 14, 2006, 3:17 AM |
shout | I love myself. | December 14, 2006, 7:00 AM |
Imperceptus | just to save you from having to type an extra colon and a null in your code? seems slightly redundant from just ? | December 15, 2006, 7:18 PM |
Myndfyr | [quote author=Imperceptus link=topic=16128.msg162640#msg162640 date=1166210338] just to save you from having to type an extra colon and a null in your code? seems slightly redundant from just ? [/quote] [code] string val = x ?? "null x"; string val = x == null ? "null x" : x; [/code] I think the first is much clearer in intent. | December 16, 2006, 2:23 AM |