public static PersonRecord CreatePersonFromString(string value) { PersonRecord per; if (string.IsNullOrEmpty(value)) throw new ArgumentNullException("input string canot be empty"); var elems = value.Split(new Char[] { ',', '|', ' ' }, StringSplitOptions.RemoveEmptyEntries); return per = new PersonRecord() { LastName = elems[0], FirstName = elems[1], Gender = elems[2], FavoriteColor = elems[3], DOB = elems[4].ToDate(), }; }
//Print the records of person to console private static void PrintToConsole(PersonRecord person) { Console.WriteLine("LastName:- {0} FirstName:- {1} Gender:- {2} FavoriteColor:- {3} Date Of Birthday:- {4}",person.LastName,person.FirstName,person.Gender,person.FavoriteColor,person.DOB.ToString("mm/dd/yyyy")); }