Ternary operator : Operators : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Operators »

 

Ternary operator









    

/*
Learning C# 
by Jesse Liberty

Publisher: O'Reilly 
ISBN: 0596003765
*/

 using System;

 public class ThreeInputValues
 {
     static void Main()
     {
         int valueOne = 10;
         int valueTwo = 20;

         int maxValue = valueOne > valueTwo ?  valueOne : valueTwo;

         Console.WriteLine("ValueOne: {0}, valueTwo: {1}, maxValue: {2}",
             valueOne, valueTwo, maxValue);

     }
 }
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Operators