Illustrates the use of the ternary operator : Operators : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Operators »

 

Illustrates the use of the ternary operator









    

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example3_5.cs illustrates the use of
  the ternary operator
*/

public class Example3_5
{

  public static void Main()
  {

    int result;

    result = 10 > 1 ? 20 : 10;
    System.Console.WriteLine("result = " + result);

    result = 10 < 1 ? 20 : 10;
    System.Console.WriteLine("result = " + result);

  }

}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Operators