C#字典Dictionary

    private Dictionary<uint, MyPet> myPets;
    public List<MyPet> GetShowPets()
    {
        List<MyPet> pets = new List<MyPet>();
        if (null != myPets)
        {
            var e = myPets.GetEnumerator();
            while (e.MoveNext())
            {
                if (CheckPetShow(e.Current.Key))
                {
                    pets.Add(e.Current.Value);
                }
            }
        }

        //根据配置表权重进行升序排序
        pets.Sort(
            delegate (MyPet pet1, MyPet pet2) 
            {
                return pet1.PetRankWeight.CompareTo(pet2.PetRankWeight);
            });

        return pets;
    }

猜你喜欢

转载自blog.csdn.net/billcyj/article/details/81015598