using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public class Animal
{
public string Name;
public int Popularity;
public Animal(string name, int popularity)
{
Name = name; Popularity = popularity;
}
}
public class AnimalCollection : Collection<Animal>
{
}
class Program
{
static void Main()
{
AnimalCollection animalAnimalCollection = new AnimalCollection();
animalAnimalCollection.Add(new Animal("Kangaroo", 10));
animalAnimalCollection.Add(new Animal("Lion", 20));
foreach (Animal a in animalAnimalCollection)
Console.WriteLine(a.Name);
}
}
The output:
Kangaroo
Lion
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |