我想定义Sorted
为ErrorProviderMessageCollection
,这是unsortedCollection
被定义为的类型。如何返回TYPED结果?
Dim Sorted As ErrorProviderMessageCollection = From item In unsortedCollection
Order By item.Control.TabIndex
我该怎么做?
Public Class ErrorProviderMessage Implements IComparable(Of ErrorProviderMessage)
Private _Message As String
Private _Control As Control
Public Sub New(ByVal message As String, ByVal control As Control)
_Message = message
_Control = control
End Sub
Public ReadOnly Property Message() As String
Get
Return _Message
End Get
End Property
Public ReadOnly Property Control() As Control
Get
Return _Control
End Get
End Property
Public Function CompareTo(ByVal other As ErrorProviderMessage) As Integer Implements System.IComparable(Of ErrorProviderMessage).CompareTo
Return Me.Control.TabIndex.CompareTo(other.Control.TabIndex)
End Function
End Class
Public Class ErrorProviderMessageCollection
Inherits System.Collections.ObjectModel.Collection(Of ErrorProviderMessage)
End Class
我改成了这一点,但它返回 “无”:昏暗分类为ErrorProviderMessageCollection = TryCast(unsortedCollection.OrderBy(功能(I)i.Control.TabIndex),ErrorProviderMessageCollection) – ChadD 2011-04-18 13:06:49
是你能够发布ErrorProviderMessageCollection的代码? – 2011-04-18 13:23:01
Plz查看更新后的帖子。 – ChadD 2011-04-18 13:25:02