vb.net.net-2.0

Similar classes with different signatures


I have two classes:


    Public Class Subscribing

    Private _subscribingObjects As IList(Of String)

    Public Sub Add(ByVal obj As SubscribeObject)
        '...code...'
    End Sub

    Public Sub Remove(ByVal index As Integer)
        '...code...'
    End Sub

    End Class

    Public Class Providing

    Private _providingObjects As IList(Of String)

    Public Sub Add(ByVal obj As ProvideObject)
        '...code...'
    End Sub

    Public Sub Remove(ByVal index As Integer)
        '...code...'
    End Sub

    End Class

Is there a more elegant way to add do this? One class would suffice, but since the Add methods have different arguments, then one really wouldn't work.

Any help would be appreciated.


Solution

  • this?

    Public Class SubscribingProviding(Of t)
    
    Private _subscribingObjects As IList(Of String)
    
    Public Sub Add(ByVal obj As t)
        '...code...'
    End Sub
    
    Public Sub Remove(ByVal index As Integer)
        '...code...'
    End Sub
    
    End Class