我正在尝试按枚举订购列表,请参见下文:
Public Class AnimalsToProcess
Implements ICloneable
Enum AnimalOrder
Dog
Cat
Horse
Fish
End Enum
Public Property _animalList As List(Of Animal)
Public Sub New()
End Sub
Function Clone() As AnimalsToProcess
End Function
Private Function ICloneable_Clone() As Object Implements ICloneable.Clone
Return Clone()
End Function
Public Sub Add(animalToAdd As Animal)
_animalList.Add(animalToAdd)
End Sub
Public Sub GetAnimals() as list(of Animal)
_animalList() 'this should be an ordered BY AnimalOrder Enum
End Sub
End Class
Add 方法由外部代码通过传递一个值来调用,例如:
animals.add(Fish)
animals.add(Horse)
animals.add(Cat)`
但是当GetAnimals
调用它时,它应该返回一个由Enum AnimalOrder
.
因此列表应按猫、马、鱼的顺序包含以下动物
谢谢你。