关于CollectionBase的成员,急!!!!!
using System;using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication53
{
public class Animals:CollectionBase
{
public void Add(Animal newAnimal)
{
List.Add(newAnimal);
}
public void Remove(Animal newAnimal)
{
List.Remove(newAnimal);
}
public Animals()
{
}
public Animal this[int animalIndex]
{
get
{
return (Animal)List[animalIndex];
}
set
{
List[animalIndex] = value;
}
}
}
}
--------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication53
{
class Program
{
static void Main(string[] args)
{
Animals animalCollection = new Animals();
animalCollection.Add(new Cow("Jack"));
animalCollection.Add(new Chicken("Vera"));
foreach (Animal myAnimal in animalCollection)
{
myAnimal.Feed();
}
Console.ReadKey();
}
}
}
----------------------------------------------------------------------------------------------
问题是:animalCollections对象调用了类Animals中的Add方法,Add方法中的List是什么东东,如果是添加一个对象,如“Jack”的话,那么animalCollections本身就是对象,向他添加一个对象是什么意思呢?难道和ArrayList定义的对象是一样意思吗?求高手解答,在线等