?? operator

x=1;
string NumberIs = (x==1)?"One":"Not Known";

Above code checks if X is queal to One then return "One" to NumberIs variable else return "Not Known"


There is another operator ?? which specifically checks for null

DataRow dr = myRow ?? DataRow.EmptyRow

This is same as:
If (myRow == null)
dr = myRow
else
dr = Datarow.EmptyRow

?? checks for left side is null or not. If it is null then it returns right part.

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database