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 HelloWorld2b
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = 214;
- char firstLetter = 'S';
- float money = 2.54f;
- string name = "Stoyan";
- bool isMail = false;
- object myObject = 5;
- int nextYear = age + 1;
- int remainder = 10; // % 3;
- remainder %= 3;
- bool test = 4 * 5 + 3 < 6 * 8 - 3;
- Console.WriteLine("Hello World!!!");
- Console.WriteLine("Max Int : " + age);
- Console.WriteLine("The first letter is: " + firstLetter);
- Console.WriteLine("I have in my pocket : " + money);
- Console.WriteLine("My name is : " + name);
- Console.WriteLine("Next year I will be: " + nextYear);
- Console.WriteLine(3 == 3);
- Console.WriteLine(remainder);
- Console.WriteLine("Please enter your age");
- string myAge = Console.ReadLine();
- int myAgeInt = int.Parse(myAge);
- Console.WriteLine("You told me. Your age is: {0}", ++myAgeInt);
- if (myAgeInt < 20)
- {
- Console.WriteLine("You are a teenager!");
- }
- else if (myAgeInt > 20 && myAgeInt < 30)
- {
- Console.WriteLine("It is time for fun!!!");
- }
- else {
- Console.WriteLine("You are aging too fast!!");
- }
- switch (myAgeInt) {
- case 20:
- Console.WriteLine("You are {0} years old", myAgeInt);
- break;
- case 30:
- Console.WriteLine("You are {0} years old", myAgeInt);
- break;
- default :
- Console.WriteLine("I don't know what to say.");
- break;
- }
- Console.WriteLine(1);
- Console.WriteLine(2);
- Console.WriteLine(3);
- // ...
- Console.WriteLine("1\n2\n3\n");
- int i = 1;
- while (i <= 10)
- {
- if (i == 5) break;
- Console.WriteLine(i);
- i++;
- }
- // break
- Console.WriteLine("Please choose:");
- Console.WriteLine("1. List the partitions");
- Console.WriteLine("2. Create a Partionion");
- Console.WriteLine("3. Delete Partition");
- Console.WriteLine("4. Exit");
- string choice;
- while (true)
- {
- choice = Console.ReadLine();
- if (int.Parse(choice) == 4) break;
- Console.WriteLine("Your choice was:" + choice);
- }
- // do-while
- i = 10;
- do
- {
- Console.WriteLine("do-while: {0}", i);
- i++;
- } while (i < 10);
- // for
- for (int j = 0; j < 10; j++)
- {
- if (j % 2 != 1)
- {
- continue;
- }
- // if (j % 2 == 1) continue;
- Console.WriteLine("for: {0}", j);
- }
- string[] group2b = { "Swetla", "Lyubo", "Krasi", "Borko", "Blago", "Miryana", "Niki", "Wqra", "Yoana" };
- foreach (string stname in group2b)
- {
- Console.WriteLine("Name: {0}", stname);
- }
- for (i = 0; i < 10; i++)
- {
- for (int j = 0; j < i; j++)
- {
- Console.Write("*");
- }
- Console.Write("\n");
- }
- // array
- /* 1)
- int[] myArray;
- myArray = new int[5];
- myArray[3] = 45;
- myArray[0] = 1;
- */
- // 2) int[] myArray = { 12, 34, 54, 67 };
- // 3)
- int[] myArray = new int[3] { 12, 34, 54 };
- for (i = 0; i < myArray.Length; i++)
- {
- Console.WriteLine(myArray[i]);
- }
- string[,] positionsOfTheStudents = {
- {"", "Vyara","","","Swetla","Lyubo","Krasi","Borko"},
- {"Yoana", "","","","","","","Blago"},
- {"", "","","","Niki","","","Miryana"}
- };
- for (i = 0; i < positionsOfTheStudents.GetLength(0); i++) {
- Console.Write("Red {0}: ", i);
- for (int j = 0; j < positionsOfTheStudents.GetLength(1); j++) {
- Console.Write(" {0}", positionsOfTheStudents[i,j]);
- }
- Console.WriteLine();
- }
- /*
- int[,] test23 = {
- {12,34},
- {23,45}
- };
- */
- int[][] jaggedArray;
- jaggedArray = new int[2][];
- jaggedArray[0] = new int[8];
- jaggedArray[1] = new int[5];
- Console.WriteLine(createString(10));
- Console.WriteLine(createString(4));
- Console.WriteLine(createString(11, "+"));
- Console.WriteLine(createString(11, "+", "Stoyan", "Yoana", "Vqra"));
- Console.WriteLine(factorial(4));
- }
- static string createString(int strLength, string str = "*", params string[] par)
- {
- string temp = "";
- for (int i = 0; i < strLength; i++) {
- temp += str; // "*";
- }
- foreach (string item in par) {
- Console.WriteLine(item);
- }
- return temp;
- }
- static string createString() {
- return "Hahha";
- }
- static int factorial(int n) {
- if (n == 0) return 1;
- // n--;
- return factorial(n - 1) * n; // --n changes the value of n
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement