Thursday, March 18, 2010

C# equivalent of sql server’s IsNull() function

For converting a null value to some other values, you can use the the null coalescing (??) operator: as shown below.

string Message = null;
string result = Message ?? "No data";
Response.Write(result);
 
The above code will print "No data" if executed.
 
You can find more information in the below link.
http://weblogs.asp.net/scottgu/archive/2007/09/20/the-new-c-null-coalescing-operator-and-using-it-with-linq.aspx

No comments:

Post a Comment