C#进阶 多个泛型约束

C#进阶 多个泛型约束_第1张图片

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class A02_Generic : MonoBehaviour
{
    [ContextMenu("测试Start")]

    // Start is called before the first frame update
    void Start()
    {
        Persons people = new Persons()
        {
            new Person("1.zhang san",1.57f,63),
            new Person("2.Li si",1.75f,59),
            new Person("3333333",1.65f,56),
            new Person("44444444",1.7f,61),

        };
        Debug.Log("原生数据");
        people.ForEach(p => Debug.Log(p));

        Debug.Log("\n身高排序");

        people.Sort(new PersonHeightCompare());
        people.ForEach(p => Debug.Log(p));


        Debug.Log("\n过滤");
        var fits = people.Filt

你可能感兴趣的:(Unity进阶,c#)