Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** A First Look at Structures *****\n");

            // Point myPoint;
            // myPoint.X = 349;
            // myPoint.Y = 76;
            // myPoint.Display();
            //
            // myPoint.Increment();
            // myPoint.Display();
            // Console.ReadLine();
            //
            // Point p1 = new Point();
            // p1.Display();
            // Console.ReadLine();
            //
            // Point p2 = new Point(50,60);
            // p2.Display();
            //
            // Console.ReadLine();
            //
            // PointWithReadOnly p3 = new PointWithReadOnly(50,60,"Point w/RO");
            // p3.Display();
            // p3.X = 120;
            // p3.Y = 340; // readonly can be assigned only in constructor
            // p3.Name = "New Name"; // readonly can be assigned only in constructor

            var s = new DisposableRefStruct(50, 60);

            s.Display();
            s.Dispose();
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** A First Look at Structures *****\n");
            // Create an initial Point.
            Point myPoint;

            myPoint.X = 349;
            myPoint.Y = 76;
            myPoint.Display();
            // Adjust the X and Y values.
            myPoint.Increment();
            myPoint.Display();
            Console.ReadLine();
            // Call custom constructor.
            Point p2 = new Point(50, 60);

            // Prints X=50,Y=60.
            p2.Display();
            PointWithReadOnly p3 =
                new PointWithReadOnly(50, 60, "Point w/RO");

            p3.Display();
            var s = new DisposableRefStruct(50, 60);

            s.Display();
            s.Dispose();
        }
Esempio n. 3
0
        async static Task Main(string[] args)
        {
            Console.WriteLine("\n=== IndicesAndRanges ===");
            IndicesAndRanges.Demo();

            Console.WriteLine("\n=== SwitchExpressions ===");
            SwitchExpressions.Demo();

            Console.WriteLine("\n=== PatternMatching ===");
            PatternMatching.Demo();

            Console.WriteLine("\n=== StaticLocalFunctions ===");
            StaticLocalFunctions.Demo();

            Console.WriteLine("\n=== UsingDeclarations ===");
            UsingDeclarations.Demo();

            Console.WriteLine("\n=== AsyncStreams ===");
            await AsyncStreams.Demo();

            Console.WriteLine("\n=== TargetTypedNew ===");
            TargetTypedNew.Demo();

            Console.WriteLine("\n=== NullCoallescingAssignment ===");
            NullCoallescingAssignment.Demo();

            Console.WriteLine("\n=== DefaultInterfaceMethods ===");
            DefaultInterfaceMethods.Demo();

            Console.WriteLine("\n=== DisposableRefStruct ===");
            DisposableRefStruct.Demo();

            Console.WriteLine("\n=== UnmanagedConstructedTypes ===");
            UnmanagedConstructedTypes.Demo();
        }
 public static void Go()
 {
     using (DisposableRefStruct disposableRefStruct = new DisposableRefStruct())
     {
     }
 }