Use if statement to check char variable value - CSharp Language Basics

CSharp examples for Language Basics:if

Description

Use if statement to check char variable value

Demo Code

class MainClass/*from w  ww  .  j  av  a2  s . c  om*/
{
   public static void Main()
   {
      char file_type = 'm';
      if ( file_type == 's' )
      {
         System.Console.WriteLine("The filer is single");
      }
      else if ( file_type == 'm' )
      {
         System.Console.WriteLine("The filer is married filing at the single rate");
      }
      else if ( file_type == 'j' )
      {
         System.Console.WriteLine("The filer is married filing at the joint rate");
      }
      else
      {
         System.Console.WriteLine("The file type is not valid");
      }
   }
}

Result


Related Tutorials