Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Exercise8UserChoiceInput
- {
- static void Main()
- {
- int intInput = 0;
- double doubleInput = 0;
- byte typeOfInput = 0;
- Console.Write("Please insert int, bool or string type: ");
- string stringInput = Console.ReadLine();
- if (int.TryParse(stringInput, out intInput))
- {
- typeOfInput = 1;
- }
- else if (double.TryParse(stringInput, out doubleInput))
- {
- typeOfInput = 2;
- }
- Console.WriteLine("\n\n");
- switch (typeOfInput)
- {
- case 1:
- Console.WriteLine("Your input data type is integer (+1): {0}\n\n", (intInput + 1));
- break;
- case 2:
- Console.WriteLine("Your input data type is double (+1): {0}\n\n", (doubleInput + 1));
- break;
- default:
- Console.WriteLine("Your input data type is string (+'*'): {0}\n\n", (stringInput + '*'));
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement