title: In C# ternary operator giving error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
body: <p>I have the following <code>C#</code> code -</p>
  
  <pre><code>using System;
  
  class Program 
  {
      static void Main()  
      {
          int number = 1;
          int isNumber10;
          (number==10)?(isNumber10=1):(isNumber10=0);
          Console.WriteLine(isNumber10);
      }
  }
  </code></pre>
  
  <p>On compilation it gives me the error -</p>
  
  <blockquote>
    <p>error CS0201: Only assignment, call, increment, decrement, and new
    object expressions can be used as a statement</p>
  </blockquote>
  
  <p>In <code>C</code> I am used to the following code -</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(){
      int isNumber10;
      int number = 1;
      (number==10)?(isNumber10=1):(isNumber10=0);
      printf("%d\n",isNumber10);
      return 0;
  }
  </code></pre>
  
  <p>And this code is running perfectly.</p>
  
  <p>Now, the two programs are exactly same. So why is it running in C but not in C#?</p>