Wednesday 15 May 2013

c# - How can I default a value set inside a Tuple to be "n/a" if it is null? -


I have this C # code:

  var result = Discendant (A + "Entry") = Content Entry. Element (A + "Content") Properties = Content. Element (M + "Properties") Notes = Properties. Element (D + "Notes") Title = Properties. Give the element (d + "Title") = Properties of the partition. Element (d + "PartitionKey") where partitionKey.Value.Substring (2, 2) == "06" & amp; Amp; Title! = Null & amp; Amp; Notes! = Select New Tupal & lt; String, string & gt; (Title.Value, notes.Value);   

This works only when I select Notes! = Null

Instead of doing so, I can set the value of notes. Value in Tuple "n / a" if notes. Price is a blank?

you ??

  New Tuples & lt; String, string & gt; (Title.Value, notes.Value ?? "n / a");   

Note that you can use Tuple.Create instead of the Tubal Creator:

  Choose Tuple.Create ( Title.Value, Notes. Value ?? "N / A");    

No comments:

Post a Comment