title: C# conditional operator - Call method if condition is true else do nothing
body: <p>C# provides <a href="https://msdn.microsoft.com/en-us/library/ty67wk28.aspx" rel="nofollow">conditional operator (?:)</a> that returns one of two values depending on the value of a Boolean expression. eg</p>
  
  <p><code>condition ? first_expression : second_expression;</code></p>
  
  <p>My question is can we use the same syntax to call a method when condition is true? and when condition is false then do nothing</p>
  
  <pre><code> public void Work(int? val)
   {
     var list = new List&lt;int&gt;();
  
     //ofcourse line below doesn't work
     //but is it possible to call method when condition is true and else do  nothing
  
     val.HasValue? list.Add(val.value) : else do nothing
  } 
  </code></pre>