Animals.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DictionaryAnimals
{
   public class Animals : DictionaryBase
   {
      public void Add(string newID, Animal newAnimal)
      {
         Dictionary.Add(newID, newAnimal);
      }

      public void Remove(string animalID)
      {
         Dictionary.Remove(animalID);
      }

      public new IEnumerator GetEnumerator()
      {
         foreach (object animal in Dictionary.Values)
            yield return (Animal)animal;
      }

      public Animal this[string animalID]
      {
         get
         {
            return (Animal)Dictionary[animalID];
         }
         set
         {
            Dictionary[animalID] = value;
         }
      }
   }

}
View Code
program.cs

相关文章:

  • 2021-12-03
  • 2022-12-23
  • 2021-11-02
  • 2021-10-02
  • 2021-05-21
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
猜你喜欢
  • 2021-10-25
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-08-08
相关资源
相似解决方案