private static void NullCoalescingOperatorExample() { NullCoalescingOperatorExample nullCoalescingOperatorExample = new NullCoalescingOperatorExample(); //nullCoalescingOperatorExample.ReferenceTypes(); nullCoalescingOperatorExample.NullableTypes(); }
static void DisplayBasics() { int test = -1; while (test != 0) { Console.ForegroundColor = ConsoleColor.DarkCyan; Console.Write("Basics - Enter exercise no: (1 to 6) "); string input = Console.ReadLine(); Console.Clear(); int.TryParse(input, out test); Console.ForegroundColor = ConsoleColor.Green; switch (test) { case 0: break; case 1: TypeCodeExample tc = new TypeCodeExample("ex. 1.1 - TypeCode Enumeration"); NullCoalescingOperatorExample nco = new NullCoalescingOperatorExample("ex. 1.2 - Null Coalescing Operator"); TestOperator to = new TestOperator("Ex. 1.3 - Test Operator", null); FormatExample fe = new FormatExample("ex. 1.4 - Format"); DelegateExample del = new DelegateExample(); del.Example("ex. 1.5 - Delegates"); del.Example(); break; case 2: DelegateExample del2 = new DelegateExample(); del2.ActionExample("ex. 2.1 - Actions / Delegates\n"); break; case 3: DelegateExample del3 = new DelegateExample(); del3.AnonymousExample("ex.3.2 - Actions / Delegates - anonymous\n"); break; case 4: DelegateExample del4 = new DelegateExample(); del4.LambdaExample("ex. 4.1 - Actions / Delegates - lambdas\n"); break; case 5: ConstructorChain cc1 = new ConstructorChain("ex. 5.1 - Constructor Chain:"); ConstructorChain cc2 = new ConstructorChain(); break; case 6: string s = "Hello Extension Methods"; int i = s.WordCount(); Console.WriteLine($"\tex. 6.1 - Extension Methods: The text \"{s}\" has {i} words"); break; default: Console.WriteLine("Not implemented!"); break; } } }