当前位置:   article > 正文

Unity中常用 : List排序_unity list排序

unity list排序
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using System.Linq;
    5. /// <summary>
    6. /// 个人信息
    7. /// </summary>
    8. public class PersonInfo
    9. {
    10.     public int ID;
    11.     public int Age;
    12.     public string Names;
    13.     public PersonInfo(int id, int age, string name, List<PersonInfo> temp = null)
    14.     {
    15.         this.ID = id;
    16.         this.Age = age;
    17.         this.Names = name;
    18.         temp?.Add(this);
    19.     }
    20. }
    21. public class ListTools : MonoBehaviour {
    22.     private List<PersonInfo> Persons = new List<PersonInfo>();
    23.     void Start () {
    24.         //一种添加方法
    25.         var a = new PersonInfo(1001, 10, "小东", Persons);
    26.         //正常添加方法
    27.         Persons.Add(new PersonInfo(1002, 15, "小马"));
    28.         Persons.Add(new PersonInfo(1003, 20, "小牛"));
    29.         Persons.Add(new PersonInfo(1004, 25, "小洗"));
    30.         this.SortType();
    31.     }
    32.     
    33.     public void SortType()
    34.     {
    35.         //
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/77410
推荐阅读
相关标签
  

闽ICP备14008679号