Hi everyone,
I'm stuck on a programming problem using Interfaces and inheritance in Vb.Net. Here is what I want to do:
I got objects TestInterfaceString, TestInterfaceInt implementing an interface ITestInterface(Of T) declaring this function: Function MyTest() As T. Nothing complicated so far.
Then I want to have a generic class handling T object where T should implement the previous interface: ITestInterface(Of T). This is working too.
Finally I want to create a class that inherits from this generic last class but then I'm fixing the type (String, Integer, etc...). This is where I'm stuck...
Below the sample code:
Thanks very much for any help...
Best regards
/Lionel Luchez
I'm stuck on a programming problem using Interfaces and inheritance in Vb.Net. Here is what I want to do:
I got objects TestInterfaceString, TestInterfaceInt implementing an interface ITestInterface(Of T) declaring this function: Function MyTest() As T. Nothing complicated so far.
Then I want to have a generic class handling T object where T should implement the previous interface: ITestInterface(Of T). This is working too.
Finally I want to create a class that inherits from this generic last class but then I'm fixing the type (String, Integer, etc...). This is where I'm stuck...
Below the sample code:
Public Interface ITestInterface(Of T)
Function MyTest() As T
End Interface
Public Class TestInterfaceString
Implements ITestInterface(Of String)
Public Function MyTest() As String Implements ITestInterface(Of String).MyTest
Return "Hello world"
End Function
End Class
Public Class AAA(Of T As ITestInterface(Of T))
Public Sub New(ByVal t As T)
Console.WriteLine(t.MyTest().ToString())
End Sub
End Class
Public Class BBB ' not working
Inherits AAA(Of TestInterfaceString) ' not working
End Class
Thanks very much for any help...
Best regards
/Lionel Luchez