Ejemplo n.º 1
0
            static void Main(string[] args)
            {
                PropertyPerson sonja = new PropertyPerson(7, "Sonja", "Olsen");

                Console.WriteLine("ID: " + sonja.Id);
                Console.WriteLine("FN: " + sonja.FirstName);
                Console.WriteLine("LN: " + sonja.LastName);
                Console.WriteLine(sonja);
                sonja[1] = "Rufus";
                Console.WriteLine(sonja);
                sonja[100] = "Felix";
                Console.WriteLine(sonja);
                sonja[0] = "Lotte";
                Console.WriteLine(sonja);


                // sonja.Id = 8;
                sonja.LastName = null;
                Console.WriteLine("LN: " + sonja.LastName);
                try {
                    sonja.LastName = "F";
                    Console.WriteLine("LN: " + sonja.LastName);
                }
                catch (ArgumentOutOfRangeException) {
                    //catch (ArgumentOutOfRangeException ex) {
                    Console.WriteLine("-- arg exp --");
                }
                catch {
                    Console.WriteLine("-- hovsa --");
                }
                Console.WriteLine();
                Console.WriteLine("Hello 4th semester");
                //Console.ReadKey();
            }
Ejemplo n.º 2
0
        public PropertyVsFieldTester()
        {
            PropertyPerson propertyPerson = new PropertyPerson()
            {
                FirstName     = "John",
                LastName      = "Smith",
                Age           = 29,
                Street1       = "West Street Rd",
                Street2       = "Apt 23",
                City          = "Lexington",
                State         = "DE",
                Zip           = "001569",
                FavoriteColor = "Blue",
                FavoriteFood  = "Cheese and Crackers",
                FavoriteSport = "Soccer",
                CreatedOn     = new DateTime(2017, 01, 01),
                IsActive      = true
            };

            propertyPeople = Enumerable.Repeat(0, 10000).Select(i => propertyPerson).ToArray();

            FieldPerson fieldPerson = new FieldPerson()
            {
                FirstName     = "John",
                LastName      = "Smith",
                Age           = 29,
                Street1       = "West Street Rd",
                Street2       = "Apt 23",
                City          = "Lexington",
                State         = "DE",
                Zip           = "001569",
                FavoriteColor = "Blue",
                FavoriteFood  = "Cheese and Crackers",
                FavoriteSport = "Soccer",
                CreatedOn     = new DateTime(2017, 01, 01),
                IsActive      = true
            };

            fieldPeople = Enumerable.Repeat(0, 10000).Select(i => fieldPerson).ToArray();
        }