SHARE
TWEET

Exercise8UserChoiceInput

g-stoyanov Nov 30th, 2012 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class Exercise8UserChoiceInput
  4. {
  5.     static void Main()
  6.     {
  7.         int intInput = 0;
  8.         double doubleInput = 0;
  9.         byte typeOfInput = 0;
  10.         Console.Write("Please insert int, bool or string type: ");
  11.         string stringInput = Console.ReadLine();
  12.         if (int.TryParse(stringInput, out intInput))
  13.         {
  14.             typeOfInput = 1;
  15.         }
  16.         else if (double.TryParse(stringInput, out doubleInput))
  17.         {
  18.             typeOfInput = 2;
  19.         }
  20.         Console.WriteLine("\n\n");
  21.         switch (typeOfInput)
  22.         {
  23.             case 1:
  24.                 Console.WriteLine("Your input data type is integer (+1): {0}\n\n", (intInput + 1));
  25.                 break;
  26.             case 2:
  27.                 Console.WriteLine("Your input data type is double (+1): {0}\n\n", (doubleInput + 1));
  28.                 break;
  29.             default:
  30.                 Console.WriteLine("Your input data type is string (+'*'): {0}\n\n", (stringInput + '*'));
  31.                 break;
  32.         }
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top