-1
我有这样的自定义分类器:排序对象不起作用
public class AlphaNumericSorter : IComparer<string>
{
public int Compare(string x, string y)
{
return SafeNativeMethods.StrCmpLogicalW(x, y);
}
}
[SuppressUnmanagedCodeSecurity]
internal static class SafeNativeMethods
{
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
public static extern int StrCmpLogicalW(string psz1, string psz2);
}
我想我所有的对象进行排序,但它只是我的专栏的排序之一,我要通过我的专栏。 我需要排序基于jointnumber
List<ViewTestPackageHistorySheet> testList = _reportTestPackageHistorySheetRepository.ShowReport(Id).ToList();
testList.Sort(new AlphaNumericSorter());
这种类型的列表,我得到这个错误:
'System.Collections.Generic.IComparer<ViewDomainClass.Report.TestPackage.ViewTestPackageHistorySheet>'
但这个工程:
List<string> testList = _reportTestPackageHistorySheetRepository.ShowReport(Id).Select(i=>i.JointNumber).ToList();
testList.Sort(new AlphaNumericSorter());
' 'System.Collections.Generic.IComparer' '不是一个错误,它只是一个命名空间?你得到的实际错误是什么? '“但是这个工作:等等......”,如果你的下一行代码行得通,那么你的问题是什么? –
DGibbs
为什么要为字符串实现一个costum分拣机? –
投票下来请评论!!!!!!! –