public static void ModeMatchSampleDisplay()
        {
            var p1 = new PersonSample("Tom Jason");
            var p2 = new PersonSample("Jack Kola");

            object[] data = { null, 42, "abstract", p1, new PersonSample[] { p1, p2 } };
            foreach (var item in data)
            {
                IsOperator(item);
            }

            foreach (var item in data)
            {
                SwitchStatement(item);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            PersonSample person = new PersonSample("Chris Xiong");

            Console.WriteLine(person.ToString());

            //using (var r = new Resource())
            //{
            //    r.Foo();
            //}
            //使用Use扩展方法实现using
            new Resource().Use(r => r.Foo());
            TupleSample.IntroTuples();
            TupleSample.TupleDecunstruction();

            var p1 = new PersonSample("Chris Xiong");

            (var firsName, var lastName) = p1;
            Console.WriteLine($"PersonSample class decunstruct as: FirstName: {firsName} LastName: {lastName}");
            ModeMatchSample.ModeMatchSampleDisplay();
        }