ArrayList 如何通过IComparable接口 实现Sort ArrayList 如何通过IComparable接口 实现Sort 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Collections;using System.Reflection;namespace Seine.Jollo3.Utility.Share{ public class ArrayListSort : IComparer { Type _type = null; string _name = string.Empty; string _direction = "ASC"; public ArrayListSort(Type type, string name, string direction) { this._type = type; this._name = name; this._direction = direction.ToUpper().Equals("DESC") ? "DESC" : "ASC"; } int IComparer.Compare( object x, object y ) { object x1 = this._type.InvokeMember(this._name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, x, null); object y1 = this._type.InvokeMember(this._name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, y, null); if(_direction.Equals("DESC")) { Swap(ref x1, ref y1); } return((new CaseInsensitiveComparer()).Compare( x1, y1 )); } void Swap(ref object x, ref object y ) { object temp = null; temp = x; x = y; y = temp; } } } ASP.NET网站,日志,后台管理。 有关Page_Load的问题 一种实现人工智能程序自进化的概念原理 关于多个Email正则验证写法 tif文件怎样可以在嵌入到Asp.Net 提交页面取返回值问题 奇怪,20pt,黑体在网页上不能完整显示 求高手给个解决方法,ACCESS被我覆盖掉了..怎么恢复啊..100分,,,, 关于电子商务。 非托管COM组件是什么?怎么用? 怎么读取word文档,使得里面的文档变成html格式的啊?高手请教 如何禁止按钮引发页面回送?
using System;
using System.Collections;
using System.Reflection;namespace Seine.Jollo3.Utility.Share
{
public class ArrayListSort : IComparer
{
Type _type = null;
string _name = string.Empty;
string _direction = "ASC"; public ArrayListSort(Type type, string name, string direction)
{
this._type = type;
this._name = name;
this._direction = direction.ToUpper().Equals("DESC") ? "DESC" : "ASC";
}
int IComparer.Compare( object x, object y )
{
object x1 = this._type.InvokeMember(this._name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, x, null);
object y1 = this._type.InvokeMember(this._name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, y, null);
if(_direction.Equals("DESC"))
{
Swap(ref x1, ref y1);
} return((new CaseInsensitiveComparer()).Compare( x1, y1 ));
}
void Swap(ref object x, ref object y )
{
object temp = null;
temp = x;
x = y;
y = temp;
}
}
}