Ejemplo n.º 1
0
        public void ICollectionExample()
        {
            try
            {
                var employeeCollection = new EmployeeICollection
                {
                    new EmployeeIEquatable {
                        Name = "Jon Snow", Rank = 1, Salary = 50000
                    },
                    new EmployeeIEquatable {
                        Name = "Nikhilesh", Rank = 2, Salary = 5000
                    },
                    new EmployeeIEquatable {
                        Name = "Mad King", Rank = 3, Salary = 55000
                    },
                    new EmployeeIEquatable {
                        Name = "Nikhilesh", Rank = 3, Salary = 65000
                    }                                                                        //Same name will not be added
                };
                MockDataUtility.PrintployeeMockArray(employeeCollection.AsEnumerable());
                Console.WriteLine($"Remove Nikhilesh (Based on Name)");
                employeeCollection.Remove(new EmployeeIEquatable {
                    Name = "Nikhilesh"
                });
                MockDataUtility.PrintployeeMockArray(employeeCollection.AsEnumerable());

                Console.WriteLine($"employeeCollection.Contains(new EmployeeIEquatable {{ Name = \"Nikhilesh\" }}) > " +
                                  $"{employeeCollection.Contains(new EmployeeIEquatable { Name = "Nikhilesh" })}");
                Console.WriteLine($"employeeCollection.Contains(new EmployeeIEquatable {{ Name = \"Mad King\" }}) > " +
                                  $"{employeeCollection.Contains(new EmployeeIEquatable { Name = "Mad King" })}");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public GenericEmployeeIEnumerator(EmployeeICollection collection)
 {
     this.collection = collection;
     currentIndex    = -1;
     Current         = default(EmployeeIEquatable);
 }