Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- string age;
- static void Main(string[] args)
- {
- #region Exe1
- Console.WriteLine("Press ESC to stop");
- do
- {
- while (!Console.KeyAvailable)
- {
- Console.WriteLine("Please do enter your name:");
- string na = Console.ReadLine();
- Console.WriteLine("Please do enter your age:");
- //string age = Console.ReadLine();
- double num;
- string age = Console.ReadLine();
- /*
- * Checking whther its a number
- * */
- if (double.TryParse(age, out num))
- {
- Console.WriteLine("Youre fine!");
- }
- else
- {
- Console.WriteLine("Renter a number");
- }
- string ad = "anon";
- if (Convert.ToInt16(age) == 20)
- {
- Console.WriteLine("Im young!");
- }
- int a = 20000;
- double b = 323.3232;
- b = a;
- a = (int)b;
- Console.WriteLine(na + " age of " + age + " lives " + "in " + ad);
- Console.WriteLine("My name is {0}, amd age of {1} lives in {2} ", na.ToUpper(), age, ad);
- if (na == "Kula" || age == "23")
- {
- Console.WriteLine("Its me");
- }
- else if (true)
- {
- Console.WriteLine("Its not me");
- }
- }
- } while (Console.ReadKey(true).Key == ConsoleKey.Enter);
- Console.WriteLine("If you wanna test again press escape");
- Console.ReadLine();
- #endregion
- #region Exe2_loops
- Console.WriteLine("type in a number : ");
- string mychar;
- int value;
- mychar = Console.ReadLine();
- value = Convert.ToInt16(mychar);
- switch (value)
- {
- case 0:
- Console.WriteLine("The case is zero");
- break;
- case 1:
- Console.WriteLine("The case is one");
- break;
- case 2:
- Console.WriteLine("The case is two");
- break;
- default:
- Console.WriteLine("The case is default");
- break;
- }
- Console.ReadLine();
- #endregion Exe2
- #region for_loops
- Console.WriteLine("Break and Continure");
- for (int i = 0; i < 10; i++)
- {
- if (i == 5)
- continue;//skippping the rest of the loop
- if (i == 7)
- break;
- Console.WriteLine("i is currently {0}", i);
- }
- Console.ReadLine();
- #endregion
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement