Esempio n. 1
0
        public void SetWorkAddress(Address address)
        {
            if (Location == null)
            {
                Location = new Location();
            }

            Location.Work = address;
        }
Esempio n. 2
0
        public void SetHomeAddress(Address address)
        {
            if (Location == null)
            {
                Location = new Location();
            }

            Location.Home = address;
        }
Esempio n. 3
0
        public static void Main()
        {
            var asyncExample = new AsyncExceptionHandlerSample();
            asyncExample.Run();

            var student = new Student("John", "Smith", new DateTime(1990, 1, 1), new DateTime(2015, 1, 1));
            WriteLine(student);
            WriteLine(student.Location?.Home?.ToString());

            var address = new Address("9049 Main St", "Maple Grove", "MN", "55311", "Apt. 10");
            student.SetHomeAddress(address);

            WriteLine("Address: ");
            WriteLine("----------------------------");
            WriteLine(student.Location?.Home?.ToString());
            WriteLine("----------------------------");
            WriteLine();

            WriteLine($"GPA (no transcript): {student.GPA:0.00}");

            try
            {
                // student.Transcript = LoadTranscript();
                student.Transcript = LoadTranscriptWithException();
                WriteLine($"GPA: {student.GPA:0.00}");
            }
            catch(Exception err) when(!Debugger.IsAttached)
            {
                WriteLine($"Error: {err.Message}");
                WriteLine($"Stack Trace:\n{err.StackTrace}");
                WriteLine("FAIL!");
            }

            // Try to dispose student using null propagation operator
            (student as IDisposable)?.Dispose();
            WriteLine("Dispose completed");
        }