ArrayList.Sort method in C#
来源:互联网 发布:unity3d编程 编辑:程序博客网 时间:2024/05/22 07:09
Today I first used the sort method of ArrayList in C#.
In order to sort the data under my business logic I designed a class inherit the IComparer interface,
then I realized the method -- Compare of the interface,in which I coded some logic to
compare two objects and return a value indication whether one is less than,equal to
or greater than the other.
There is a simple sample here
ArrayList myAL = new ArrayList();
myAL.Add("The");
myAL.Add("QUICK");
myAL.Add("BROWN");
IComparer myComparer = new myCompare();
myAL.Sort(0, 3, myComparer);
public class myCompare : IComparer
{
int IComparer.Compare(Object x, Object y)
{
return ((new CaseInsensitiveComparer()).Compare(y, x));
}
}
myAL.Add("The");
myAL.Add("QUICK");
myAL.Add("BROWN");
IComparer myComparer = new myCompare();
myAL.Sort(0, 3, myComparer);
public class myCompare : IComparer
{
int IComparer.Compare(Object x, Object y)
{
return ((new CaseInsensitiveComparer()).Compare(y, x));
}
}
I think the sort way of ArrayList designed in C# is great , we can sort the elements in any way we want
- ArrayList.Sort method in C#
- C# Arraylist的sort函数的用法
- C# ArrayList 的Sort函数使用
- Numeric String Sort in C#
- sort--ArrayList
- ArrayList.Sort()
- Dynamic in C# VII: Phantom Method Semantics
- c# ArrayList 的 Sort()方法的使用
- c# ArrayList 的 Sort()方法的使用
- c# ArrayList 的 Sort()方法的使用
- c# ArrayList 的 Sort()方法的使用
- c# ArrayList 的 Sort()方法的使用
- c# 学习笔记 ArrayList的Sort方法的实现
- Java Sort Arraylist
- How to Sort Arraylist
- ArrayList排序sort()方法
- C#ArrayList-sort
- Arraylist排序(sort)
- 用PHP制作静态网站的模板框架
- 模板引擎SMARTY
- 实例学习PHP之FastTemplate模板篇
- 超越模板引擎
- 在PHP世界中选择最合适的模板--比较PHPLIB Template和FastTemplate
- ArrayList.Sort method in C#
- 我是一个黑客
- 令人喷饭的留言板
- JXTA promotion 3, basic concepts
- 两强相争,谁为王者?——Java vs. .NET
- C#命名规则和开发习惯
- 强烈建议每一个想成功的程序员读一读此文章[转载]
- 使用C#进行点对点通讯和文件传输(发送接收部分)
- 接口和口罩