日期:2014-05-19  浏览次数:20972 次

请各位帮我看下这个程序
昨晚编译《C#入门经典》一例题时出现了错误“Ch12Ex04.Farm <T> ”不会实现接口成员“System.Collections.Generic.IEnumerable <T> .GetEnumerator()” E:\BegVCSharp\Chapter12\Ch12Ex04\Ch12Ex04\Farm.cs
可是我在泛型类Farm中已经实现了接口IEnumerable,不知道到底错在哪里,下面是我的源代码:
Animal.cs
using   System;
using   System.Collections.Generic;
using   System.Text;
using   System.Collections;

namespace   Ch12Ex04
{
        public   abstract   class   Animal
        {
                protected   string   name;
                public   string   Name
                {
                        get
                        {
                                return   name;
                        }
                        set
                        {
                                name   =   value;
                        }
                }
                  //构造函数
                public   Animal()
                {
                        name   =   "The   Animal   with   no   name. ";
                }
                public   Animal(string   newName)
                {
                        name   =   newName;
                }
                public   void   Feed()
                {
                        Console.WriteLine( "{0}   has   been   fed. ",   name);
                }
                //抽象方法
                public   abstract   void   MakeANoise();
        }
}
--------------------------------
--------------------------------
Chicken.cs
using   System;
using   System.Collections.Generic;
using   System.Text;

namespace   Ch12Ex04
{
        public   class   Chicken:Animal
        {
                public   void   LayEgg()