Advertisement
wingman007

IntroC#_types_variables_operators_console_if_1a

Sep 14th, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HelloWorld
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int age = 50;
  14.             int colegeTest = 10 + ++age;
  15.             age +=23;
  16.             int test2 = 10 + 34* 8;
  17.             char firstLetter = 'S';
  18.             float myMoney = 2.34f;
  19.             string name = "Stoyan";
  20.             sbyte test = -128;
  21.             bool isMail = true;
  22.  
  23.             object myObject = 5;
  24.  
  25.             int result = age + test;
  26.  
  27.             bool logResult = age < test;
  28.  
  29.             Console.WriteLine("Hello World! I am " + age + " years old. My name starts with " + firstLetter + "My money " + myMoney);
  30.             Console.WriteLine("My name is " + name + test);
  31.             Console.WriteLine("My I a mail: " + isMail);
  32.             Console.WriteLine("Result " + result);
  33.             Console.WriteLine("loResult " + logResult);
  34.             Console.WriteLine("colege " + colegeTest);
  35.  
  36.            //  string readCOnsole = Console.ReadLine();
  37.            //  Console.WriteLine("You have entered " + int.Parse(readCOnsole));
  38.  
  39.             Console.WriteLine("Please eneter your age: ");
  40.             int userAge = int.Parse(Console.ReadLine());
  41.  
  42.             /*
  43.             if (userAge < 20)
  44.             {
  45.                 Console.WriteLine("You are an teenager!!!");
  46.             }
  47.             else if (userAge < 50 && userAge > 30) {
  48.                 Console.WriteLine("You are in the middle age");
  49.             }
  50.             else {
  51.                 Console.WriteLine("You are not in our age ranges");
  52.             }
  53.             */
  54.  
  55.             switch (userAge)
  56.             {
  57.                 case 20:
  58.                     Console.WriteLine("You are 20 years old");
  59.                     break;
  60.                
  61.                 default:
  62.                     Console.WriteLine("Nothing else matches");
  63.                     break;
  64.             }
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement