按顺序比较大小
2016-01-15 22:16
375 查看
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; } } }
相关文章推荐
- Syntax error, annotations are only available if source level is 1.5
- 启动控制面板中的applet时的一点笔记--发文于2013-10-22
- 用 IntelliJ IDEA 15.x 创建并发布JavaWeb项目
- 使用Visual Studio对项目重命名
- Codeforces Gym 100231L Intervals 数位DP
- 搭建 hexo,在执行 hexo deploy 后,出现 error deployer not found:github 的错误
- 【HTML/XML 8】XSL,可扩展样式表语言
- 【LeetCode-326】Power of three 上(C++)
- 1012: [JSOI2008]最大数maxnumber
- 【HTML/XML 8】XSL,可扩展样式表语言
- 类似于qq音乐底部弹出的popwindow
- 【总结】EJB开发过程中遇到的几个问题
- ioctl接口
- Linux bash中的变量分类
- HIVE INSTALLATION
- ntfs物理磁盘解析 --发文于2013-9-24
- CortexM3
- jquery ui 学习随笔 自动补全
- akka-actor(嘿咻demo)
- 2016