static void Main()
        {
            WriteLine("1. SWITCH EXPRESSIONS");
            WriteLine($"Legacy switch: {SwitchExpressions.FromRainbow(Rainbow.Violet)}");
            WriteLine($"Expressive switch: {SwitchExpressions.TasteTheRainbow(Rainbow.Red)}");
            WriteLine();

            WriteLine("2. PROPERTY PATTERNS");
            var brookfieldSalesTax =
                PropertyPatterns.ComputeSalesTax(
                    new Address {
                State = "WI", City = "Brookfield"
            },
                    100);

            WriteLine($"Brookfiled Sales Tax:{brookfieldSalesTax}");

            var milwaukeeSalesTax =
                PropertyPatterns.ComputeSalesTax(
                    new Address {
                State = "WI", City = "Milwaukee"
            },
                    100);

            WriteLine($"Milwaukee Sales Tax: {milwaukeeSalesTax}");
            WriteLine();

            WriteLine("3. TUPLE PATTERNS");
            WriteLine($"{TuplePatterns.RockPaperScissors("rock", "rock")}");
            WriteLine($"{TuplePatterns.RockPaperScissors("rock", "paper")}");
            WriteLine($"{TuplePatterns.RockPaperScissors("scissors", "paper")}");
            WriteLine($"{TuplePatterns.RockPaperScissors("rock", "scissors")}");
            WriteLine();

            WriteLine("4. OBJECT PATTERNS");
            WriteLine($"Square: {ObjectPatterns.ShapeDetails(new Rectangle(7, 7))}");
            WriteLine();

            WriteLine("POSITIONAL PATTERNS");
            WriteLine($"Point quadrant = {PositionalPatterns.AsQuadrant(new Point(-3, 9))}");
            WriteLine();
        }
Beispiel #2
0
        static async Task Main(string[] args)
        {
            var ascData = Enumerable.Range(1, 7).ToArray();
            var asc     = new AsyncStreamConsumer <int>(ascData, TimeSpan.FromSeconds(.5));
            //await asc.ConsumeStream();

            var iar = new IndicesAndRanges();
            //iar.PrintExamples();

            var rom = new ReadonlyMembers(1, 7, 12);
            //Console.WriteLine(rom.D);
            //Console.WriteLine(rom.Roots());

            var dim1  = new DefaultInterfaceMethods1(Enumerable.Range(1, 100).ToList());
            var idim1 = (IDefaultInterfaceMethods1)dim1;

            // Call Count in DefaultInterfaceMethods (!)
            //Console.WriteLine(idim1.Count);
            //Console.WriteLine(dim1.Count);

            var dim2  = new DefaultInterfaceMethods2(Enumerable.Range(1, 100).ToList());
            var idim2 = (IDefaultInterfaceMethods1)dim2;

            // It is not possible call Count directly
            //Console.WriteLine(idim2.Count);
            //Console.WriteLine(((IDefaultInterfaceMethods)dim2).Count);

            var pp1 = new PositionalPatterns <char>("jedna dve");

            (var head1, var tail1) = pp1;
            //Console.WriteLine(head1);
            //Console.WriteLine(string.Join(string.Empty, tail1));

            var pp2 = new PositionalPatterns <char>("");

            (var head2, var tail2) = pp2;
            //Console.WriteLine(head2);
            //Console.WriteLine(string.Join(string.Empty, tail2));

            var nol = await UsingDeclarations.nol("jedna" + Environment.NewLine + "dve honza" + Environment.NewLine + "jde");

            //Console.WriteLine(nol);

            //var p0 = StaticLocalFunctions.FibNum(0);
            //var p1 = StaticLocalFunctions.FibNum(1);
            //var p2 = StaticLocalFunctions.FibNum(2);
            //var p7 = StaticLocalFunctions.FibNum(6);
            //Console.WriteLine(p0);
            //Console.WriteLine(p1);
            //Console.WriteLine(p2);
            //Console.WriteLine(p7);

            //Console.WriteLine(string.Join(' ', StaticLocalFunctions.FibSeq(20)));

            //RefStructDispose();

            //var nca1 = new NullcoalescingAssignment();

            //var def = nca1.Add(default);
            //var val = nca1.Add("value");

            //Console.WriteLine(def);
            //Console.WriteLine(val);

            //Console.WriteLine(string.Join(',', nca1.Data));
            //Console.WriteLine();

            //var nca2 = new NullcoalescingAssignment(nca1.Data);

            //nca2.Add("Data");

            //Console.WriteLine(string.Join(',', nca2.Data));

            UnmanagedConstructedTypes.DisplaySize();

            Console.ReadLine();
        }