static void Main() { Person spiro = new Person("Spiro", 33, "*****@*****.**"); System.Console.WriteLine(spiro); Person kiro = new Person("Kiro", 22); System.Console.WriteLine(kiro); try { Person miro = new Person("", 44, "*****@*****.**"); } catch (ArgumentException aex) { Console.Error.WriteLine(aex.Message); } try { Person miro = new Person("Miro", 101, "*****@*****.**"); } catch (ArgumentException aex) { Console.Error.WriteLine(aex.Message); } try { Person miro = new Person("Miro", 11, "mail"); } catch (ArgumentException aex) { Console.Error.WriteLine(aex.Message); } }
static void Main() { Person gosho = new Person("Gosho", 21, "*****@*****.**"); Person tosho = new Person("Tosho", 30); Console.WriteLine(gosho.ToString()); Console.WriteLine(tosho.ToString()); }
static void Main() { Console.WriteLine("Enter name..."); var name = Console.ReadLine(); Console.WriteLine("Enter age..."); var age = int.Parse(Console.ReadLine()); Console.WriteLine("Enter email..."); var email = Console.ReadLine(); if (!email.Equals("")) { Person person = new Person(name, age, email); Console.WriteLine(person); } else { Person person = new Person(name, age); Console.WriteLine(person); } }