How to use short-form if (conditional ternary operator) in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 12, b = 20;

            int c = (a > b) ? a : b;

            Console.WriteLine(c);
        }
    }
}

/*
run:
    
20
   
*/

 



answered May 27, 2017 by avibootz

Related questions

...