?

Log in

Hey There

tobes31415 in tobes31415_code

C# Null Coalescing Operator: ??

I just discovered that there is a null coalescing operator in C# that can be used to supply default values when an object being referenced is null.

Here is a silly, trivial example. (I'm very busy right now I'm primarily writing this post so I don't forget about it myself)

[WebMethod]
public String FindLog(double Value, int? Base)
{
//If the user didn't specify the base we assume base 2
return Math.Log (Value, (Base ?? 2));
}

Comments

January 2009

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728293031
Powered by LiveJournal.com