0
在下面的例子中,我想將.sort()方法隱藏到客戶端,我怎麼能實現這一點?隱藏VB.NET中的一個集合
Namespace test
Class Figure
Implements IComparable(Of Figure)
Public Property Area As Double
Public Function CompareTo(ByVal other As Figure) As Integer Implements System.IComparable(Of Figure).CompareTo
CompareTo = Me.Area.CompareTo(other.Area)
End Function
End Class
Class Figures
Inherits System.Collections.Generic.List(Of Figure)
Public Shadows Sub Add(ByVal nieuweFiguur As Figure)
MyBase.Add(nieuweFiguur)
Me.Sort()
End Sub
End Class
Class Client
Public Shared Sub Main()
Dim figures As New Figures
figures.Add(New Figure With {.Area = 12})
figures.Add(New Figure With {.Area = 16})
'***********************************************************
figures.Sort() 'i want to hide the sort method to the client
'***********************************************************
End Sub
End Class
End Namespace
謝謝喬恩,我走錯了路,你展示了正確的方式 – peter 2013-03-08 21:15:50