Created
June 18, 2015 02:27
-
-
Save Mooophy/1d5f6ab2d394d8c08481 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication1 | |
| { | |
| public class Program | |
| { | |
| private static Dictionary<int, string> myDictionary = new Dictionary<int, string>(); | |
| private static int value = 0; | |
| private static void Main(string[] args) | |
| { | |
| try | |
| { | |
| for (int i = 0; i < 10; ++i) | |
| { | |
| if (i == 0) | |
| { | |
| Test0(); | |
| Console.WriteLine("Test0 = " + i.ToString()); | |
| } | |
| else if (i == 1) | |
| { | |
| Test1(i); | |
| Console.WriteLine("Test1 = " + i.ToString()); | |
| } | |
| else if (i == 2 && i % 2 == 0) | |
| { | |
| Test2(ref i); | |
| Console.WriteLine("Test2 = " + i.ToString()); | |
| } | |
| else if (i == 2) | |
| { | |
| Test1(i); | |
| Console.WriteLine("Test1 = " + i.ToString()); | |
| } | |
| else if (i == 3) | |
| { | |
| Test3(ref i); | |
| } | |
| else if (i == 4) | |
| { | |
| string str; | |
| str = Test4(i); | |
| Console.WriteLine("Test4 = " + (int.Parse(str) + i)); | |
| } | |
| else if (i == 5) | |
| { | |
| Test5(i); Test5(i - 2); | |
| } | |
| else if (i == 6) | |
| { | |
| Test6(ref i); | |
| Console.WriteLine("Added item to dictionary."); | |
| } | |
| else if (myDictionary[i] == "six") | |
| { | |
| Console.WriteLine("Item 6 is in the dictionary."); | |
| } | |
| else | |
| { | |
| Console.WriteLine("Entered else clause"); | |
| int zero = 0; | |
| int result = i / zero; | |
| Console.WriteLine("Result is " + result.ToString()); | |
| } | |
| } | |
| Console.WriteLine("End of loop reached"); | |
| } | |
| catch | |
| { | |
| Console.WriteLine("Catch clause entered"); | |
| } | |
| finally | |
| { | |
| Console.WriteLine("Finally clause entered"); | |
| } | |
| Console.WriteLine("Finished"); | |
| } | |
| private static void Test0() | |
| { | |
| int result = 0; | |
| for (int i = 1; i <= 3; i++) | |
| { | |
| for (int j = 1; j <= 2; j++) | |
| { | |
| result += i;//result = result + i; | |
| } | |
| } | |
| Console.WriteLine("Test0 = " + result.ToString());//// | |
| } | |
| private static void Test1(int i) | |
| { | |
| i = 3; | |
| } | |
| private static void Test2(ref int i) | |
| { | |
| i = 2; | |
| } | |
| private static void Test3(ref int i) | |
| { | |
| i = Convert.ToInt32(i + "1") % 9; | |
| } | |
| private static string Test4(int i) | |
| { | |
| string str; | |
| str = i.ToString() + i.ToString(); return str; | |
| } | |
| private static void Test5(int i) | |
| { | |
| Program.value -= i; | |
| Console.WriteLine("Test5 = " + Program.value.ToString()); | |
| } | |
| private static void Test6(ref int i) | |
| { | |
| myDictionary.Add(i, "six"); | |
| Console.WriteLine("Test6 = " + myDictionary[i]); | |
| } | |
| } | |
| }//namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment