zoukankan      html  css  js  c++  java
  • 按顺序比较大小

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication11
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                Petss[] pet = new Petss[]{
                new Petss(){name="张三",age=110},
                new Petss(){name="张1三",age=11},
                new Petss(){name="张2三",age=40}
                };
                Array.Sort(pet);
                foreach (var item in pet)
                {
                    Console.WriteLine(item.age);
                }
    
                Console.ReadKey();
    
                int[] arr = { 1, 2, 3, 4, 5 };
                //  arr.OrderBy()
                // arr.OrderBy
    
            }
        }
    
    
        class Petss : IComparable
        {
    
            public int age { set; get; }
            public string name { set; get; }
    
    
            public int CompareTo(object obj)
            {
                Petss p = (Petss)obj;
                return p.age - this.age;
    
            }
        }
    }
    

      

  • 相关阅读:
    解析库之 beautifulsoup模块
    请求库之 selenium模块
    请求库之 requests模块
    一句话
    JPA学习03
    JPA学习02
    JPA学习01
    SpringData学习04
    SpringData学习03
    SpringData学习02
  • 原文地址:https://www.cnblogs.com/xh0626/p/5134633.html
Copyright © 2011-2022 走看看