Advertisement
Kulasangar

Day one

Dec 14th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.48 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 ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.  
  12.         string age;
  13.  
  14.         static void Main(string[] args)
  15.         {
  16.  
  17.             #region Exe1
  18.  
  19.             Console.WriteLine("Press ESC to stop");
  20.             do
  21.             {
  22.                 while (!Console.KeyAvailable)
  23.                 {
  24.                     Console.WriteLine("Please do enter your name:");
  25.                     string na = Console.ReadLine();
  26.                     Console.WriteLine("Please do enter your age:");
  27.                     //string age = Console.ReadLine();
  28.  
  29.                     double num;
  30.                     string age = Console.ReadLine();
  31.  
  32.                     /*
  33.                      * Checking whther its a number
  34.                      * */
  35.  
  36.                     if (double.TryParse(age, out num))
  37.                     {
  38.                         Console.WriteLine("Youre fine!");
  39.                     }
  40.                     else
  41.                     {
  42.  
  43.                         Console.WriteLine("Renter a number");
  44.  
  45.  
  46.                     }
  47.  
  48.                     string ad = "anon";
  49.  
  50.                     if (Convert.ToInt16(age) == 20)
  51.                     {
  52.                         Console.WriteLine("Im young!");
  53.                     }
  54.  
  55.                     int a = 20000;
  56.                     double b = 323.3232;
  57.                     b = a;
  58.                     a = (int)b;
  59.  
  60.                     Console.WriteLine(na + " age of " + age + " lives " + "in " + ad);
  61.                     Console.WriteLine("My name is {0}, amd age of {1} lives in {2} ", na.ToUpper(), age, ad);
  62.  
  63.                     if (na == "Kula" || age == "23")
  64.                     {
  65.                         Console.WriteLine("Its me");
  66.                     }
  67.                     else if (true)
  68.                     {
  69.                         Console.WriteLine("Its not me");
  70.  
  71.                     }
  72.                 }
  73.  
  74.             } while (Console.ReadKey(true).Key == ConsoleKey.Enter);
  75.  
  76.             Console.WriteLine("If you wanna test again press escape");
  77.  
  78.  
  79.             Console.ReadLine();
  80.  
  81.             #endregion
  82.  
  83.             #region Exe2_loops
  84.  
  85.             Console.WriteLine("type in a number : ");
  86.  
  87.  
  88.  
  89.             string mychar;
  90.             int value;
  91.  
  92.             mychar = Console.ReadLine();
  93.  
  94.             value = Convert.ToInt16(mychar);
  95.             switch (value)
  96.             {
  97.                 case 0:
  98.                     Console.WriteLine("The case is zero");
  99.                     break;
  100.  
  101.                 case 1:
  102.                     Console.WriteLine("The case is one");
  103.                     break;
  104.  
  105.                 case 2:
  106.                     Console.WriteLine("The case is two");
  107.                     break;
  108.  
  109.                 default:
  110.                     Console.WriteLine("The case is default");
  111.                     break;
  112.  
  113.             }
  114.  
  115.             Console.ReadLine();
  116.  
  117.  
  118.             #endregion Exe2
  119.  
  120.             #region for_loops
  121.  
  122.             Console.WriteLine("Break and Continure");
  123.  
  124.             for (int i = 0; i < 10; i++)
  125.             {
  126.  
  127.                 if (i == 5)
  128.  
  129.                     continue;//skippping the rest of the loop
  130.  
  131.                 if (i == 7)
  132.  
  133.                     break;
  134.  
  135.                 Console.WriteLine("i is currently {0}", i);
  136.  
  137.             }
  138.  
  139.             Console.ReadLine();
  140.  
  141.             #endregion
  142.  
  143.         }
  144.  
  145.  
  146.     }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement