J
James.R.Thigpen
Hello,
Here is what I'm trying to do.
Public Class Part
End Class
Public Class SpecialPart
Inherits Part
End Class
Public Class FormManagerTest
Public Delegate Function PartGetter(ByVal id As Integer) As Part
Public Function GetPart(ByVal id As Integer) As Part
Return New Part
End Function
Public Function GetSpecialPart(ByVal id As Integer) As SpecialPart
Return New SpecialPart
End Function
End Class
Public Class Test
Sub Main()
Dim fm As New FormManagerTest
Dim getter1 As FormManagerTest.PartGetter
Dim getter2 As FormManagerTest.PartGetter
getter1 = AddressOf fm.GetPart
getter2 = AddressOf fm.GetSpecialPart
getter1.Invoke(1)
getter2.Invoke(1)
End Sub
End Class
Essentially I want to use a Delegate to refer to a function where the
return type of the function is a type derived from the return type of
the delegate. in this example getter2 = AddressOf fm.GetSpecialPart
compains "Error 104 Method 'Public Function GetSpecialPart(id As
Integer) As UnitTests.SpecialPart' does not have the same signature as
delegate 'Delegate Function PartGetter(id As Integer) As Part'."
I know this is probably the way it's supposed to be, but I'm wondering
what I should do in this scenario. Any advice or best practices or
anything? Am I don't something completely braindead, because I am
fairly new to delegates and that could very well be the case
Thanks,
James Thigpen
http://www.jamesthigpen.com
Here is what I'm trying to do.
Public Class Part
End Class
Public Class SpecialPart
Inherits Part
End Class
Public Class FormManagerTest
Public Delegate Function PartGetter(ByVal id As Integer) As Part
Public Function GetPart(ByVal id As Integer) As Part
Return New Part
End Function
Public Function GetSpecialPart(ByVal id As Integer) As SpecialPart
Return New SpecialPart
End Function
End Class
Public Class Test
Sub Main()
Dim fm As New FormManagerTest
Dim getter1 As FormManagerTest.PartGetter
Dim getter2 As FormManagerTest.PartGetter
getter1 = AddressOf fm.GetPart
getter2 = AddressOf fm.GetSpecialPart
getter1.Invoke(1)
getter2.Invoke(1)
End Sub
End Class
Essentially I want to use a Delegate to refer to a function where the
return type of the function is a type derived from the return type of
the delegate. in this example getter2 = AddressOf fm.GetSpecialPart
compains "Error 104 Method 'Public Function GetSpecialPart(id As
Integer) As UnitTests.SpecialPart' does not have the same signature as
delegate 'Delegate Function PartGetter(id As Integer) As Part'."
I know this is probably the way it's supposed to be, but I'm wondering
what I should do in this scenario. Any advice or best practices or
anything? Am I don't something completely braindead, because I am
fairly new to delegates and that could very well be the case
Thanks,
James Thigpen
http://www.jamesthigpen.com