Exemple #1
0
 private static void ShowOffChildNameSafely(Person phill)
 {
     var childName = phill.SafelyExp(x => x.Child.Name, "n/a");
     Console.WriteLine();
     Console.WriteLine("Getting Phill's child name safely.");
     Console.WriteLine("Phill's child name: {0}", childName);
 }
Exemple #2
0
 private static void ShowOffChildNameRecklessly(Person phill)
 {
     try
     {
         Console.WriteLine();
         Console.WriteLine("Getting Phill's child name recklessly.");
         var compilerWantsMe = phill.Child.Name;
     }
     catch (NullReferenceException nullEx)
     {
         Console.WriteLine("Exception here!!! {0}", nullEx.Message);
     }
 }