在下面的示例中,我想向客户端隐藏 .sort() 方法,我该如何实现?
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