Using the if...else statement - CSharp Language Basics

CSharp examples for Language Basics:if

Description

Using the if...else statement

Demo Code

class stacked//from  www .  j a va2 s  .com
{
   static void Main()
   {
      char gender = 'x';
      if( gender == 'm' )
      {
         System.Console.WriteLine("The gender is male");
      }
      else if ( gender == 'f' )
      {
         System.Console.WriteLine("The gender is female");
      }
      else
      {
         System.Console.WriteLine("The gender value, {0}, is not valid", gender);
      }
      System.Console.WriteLine("The if statement is now over!");
   }
}

Result


Related Tutorials