static void Main(string[] args) { Customer sally = new Customer { FirstName = "Sally", LastName = "Williams", Age = 23, Birthday = 2028 }; Customer mike = new Customer { FirstName = "Mike", LastName = "Harrison", Age = 10, Birthday = 2019 }; Console.WriteLine(" {0} {1} \n Age: {2} \n Birthday: {3} ", sally.FirstName, sally.LastName, sally.Age, sally.Birthday); Console.WriteLine("\n {0} {1} \n Age: {2} \n Birthday: {3} ", mike.FirstName, mike.LastName, mike.Age, mike.Birthday); Debug.Assert(mike.Age == 10, "Sally is 10."); Debug.Assert(sally.Age == 23, "Sally is 23."); Debug.Assert(mike.Age > 5 && sally.Age > 21, "Mike or Sally are too young."); Console.ReadKey(); }
static void Main(string[] args) { Customer cust1 = new Customer() { FirstName = "Sally", LastName = "Williams", Age = 23, Birthdate = DateTime.Parse("2028-01-01") }; Customer cust2 = new Customer() { FirstName = "Mike", LastName = "Harrison", //Age = 10, Age = -5, Birthdate = DateTime.Parse("2019-01-01") }; Debug.Assert(cust1.Age == 23, "Sally is 23."); //Debug.Assert(cust2.Age == 10, "Mike is 10."); Debug.Assert(cust2.Age == 0, "Mike cannot be younger than 0."); //pause Console.ReadLine(); }
static void Main(string[] args) { var customer1 = new Customer { FirstName = "Sally", LastName = "Williams", Age = 23, Birthdate = 2028 }; var customer2 = new Customer { FirstName = "Mike", LastName = "Harrison", Age = 10, Birthdate = 2019 }; Debug.Assert(customer1.Birthdate == 2028, "Sally's birthdate is 2028"); Debug.Assert(customer2.Age == 10, "Mike is 10"); customer2.Age = -5; Debug.Assert(customer2.Age == 0, "Mike cannot be younger than 0."); }
static void Main(string[] args) { var sally = new Customer { FirstName = "Sally", LastName = "Williams", DOB = new DateTime(2028, 6, 10), Age = 23 }; Debug.Assert(sally.Age == 28, "Sally is 23."); Console.ReadLine(); var mike = new Customer { FirstName = "Mike", LastName = "Harrison", DOB = new DateTime(2019, 6, 10), Age = 10 }; Debug.Assert(mike.Age == 10, "Mike is 10."); Console.ReadLine(); }