我有一个P_apps.vb类
<Serializable()> _
<DefaultProperty("Items")> _
Public Class P_apps
Inherits AbstractEntity
Private mintID As Int32 = 0
Private mstrStatus As String = ""
Private mstrApplicationType As String = ""
Private mstrLastName As String = ""
Private mstrFirstName As String = ""
Private mstrMiddleName As String = ""
'other properties
Private mstrItems As String = ""
Public Sub New(ByVal Items As String)
mstrItems = Items
End Sub
Default Public Property Items(ByVal col As String) As String
Get
Return mstrItems
End Get
Set(ByVal value As String)
mstrItems = value
End Set
End Property
'other properties
End Class
然后我有另一个部分类Online_apps.aspx.vb
Partial Public Class Online_apps
Inherits BasePage
Implements System.Collections.IComparer
Dim mcolApps As New SBECollection(Of P_apps)
'Some coding
Dim _lstColumns As New List(Of String)
Public Function Sortcompare(ByVal vobjPSA As Object, ByVal vobjPSB As Object) As Integer Implements IComparer.Compare
Dim intSortReturn As Integer = 0
_lstColumns.ForEach(Function(rstrCol) Colsort(rstrCol, intSortReturn, CType(vobjPSA, P_apps), CType(vobjPSB, P_apps)))
End Function
Public Function Colsort(ByVal rstrCol As String, ByRef intSortReturn As Integer, ByVal vobjPSA As P_apps, ByVal vobjPSB As P_apps) As Integer
If (intSortReturn = 0) Then
If (vobjPSA(rstrCol) < vobjPSB(rstrCol)) Then
intSortReturn = -1
ElseIf (vobjPSA(rstrCol) > vobjPSB(rstrCol)) Then
intSortReturn = 1
End If
End If
Return Nothing
End Function
Private Function GetP_apps() As SBECollection(Of P_apps)
'Some coding
mcolApps.ToList.Sort(AddressOf Sortcompare)
Return mcolApps
End Function
End Class
我在Online_apps的Page_Load中调用函数GetP_apps()
我的SBECollection定义为
Public Class SBECollection(Of t As AbstractEntity)
Inherits System.Collections.CollectionBase
Member of SBEFramework
由我公司定义
我在SortCompare的foreach循环中的ColSort函数未被调用。 而SortCompare始终为0。
任何人都可以帮助我吗