-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分揀機? –
投票下來請評論!!!!!!! –