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.
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.
No comments :
Post a Comment
What are your thoughts on this post? Did you like it?