在研发过程,把做工程过程较好的一些内容片段做个珍藏,下面的资料是关于C# List<T>进行多字段排序的内容,应该对大家也有用途。
IList List = new List();
string[] property = new string[] { “column1”,“column2” };
bool[] sort =new bool[]{ false,false };
List = new IListSort(List, property,sort).Sort();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace Common
{
public class IListSort
{
private string[] _propertyName;
private bool[] _sortBy;
private IList _list;
public IListSort(IList<T> list, string[] propertyName, bool[] sortBy)
{
_list = list;
_propertyName = propertyName;
_sortBy = sortBy;
}
public IListSort(IList<T> list, string[] propertyName)
{
_list = list;
_propertyName = propertyName;
for (int