From 7d757ede3577088e6b3c7040b3b551b24e74e865 Mon Sep 17 00:00:00 2001 From: Mostafa Kazemi Date: Wed, 28 Oct 2020 19:12:03 +0330 Subject: [PATCH] checked Null another way --- MoreExamples2/Program.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/MoreExamples2/Program.cs b/MoreExamples2/Program.cs index 91072bc..c2381de 100644 --- a/MoreExamples2/Program.cs +++ b/MoreExamples2/Program.cs @@ -17,14 +17,23 @@ public static string Name static void Main(string[] args) { - Name = null; - + //Name = null; //if (Name == null) // throw new ArgumentNullException(nameof(Name),"Name Must Not be null"); + //Console.WriteLine(Name); + - Console.WriteLine(Name); + Person p = new Person(); + p.Name = "Mossy"; + Console.WriteLine($"Name : {p?.Name}"); // check to see if it's null } } + + class Person + { + public string Name { get; set; } + + } }