Example #1
0
    static void DoSomethingWithPropertyValues(Students students, eStudentProperty propertyToIterate)
    {
        // This method demonstrates use of the Students.PropertyValues method.
        // The property being iterated is determined by the propertyToIterate parameter,
        // therefore, this method cannot know which specific iterator method to call.
        // It will use the PropertyValues method instead.
        Console.WriteLine("Outputting values for the {0} property.", propertyToIterate);
        int index = 0;

        foreach (object value in students.PropertyValues(propertyToIterate))
        {
            Console.WriteLine("{0}: {1}", index++, value);
        }
    }
Example #2
0
    public IEnumerable PropertyValues(eStudentProperty property)
    {
        switch (property)
        {
        case eStudentProperty.Name:
            return(this.Names());

        case eStudentProperty.City:
            return(this.Cities());

        case eStudentProperty.Age:
            return(this.Ages());

        default:
            throw new ArgumentOutOfRangeException("property");
        }
    }