Skip to content

Instantly share code, notes, and snippets.

@chrissie1
Created August 16, 2012 18:53
Show Gist options
  • Save chrissie1/3372616 to your computer and use it in GitHub Desktop.
Save chrissie1/3372616 to your computer and use it in GitHub Desktop.
this should fail. In old VB.
Imports System.Dynamic
Module Module1
Sub Main()
Dim c2 As Object = New C
Dim db2 As Object = New D
c2.Join(db2.Address)
End Sub
End Module
Class C : Inherits DynamicObject
Public Overrides Function TryInvokeMember(binder As System.Dynamic.InvokeMemberBinder, args() As Object, ByRef result As Object) As Boolean
If binder.Name = "Join" Then
result = args(0) & args(0)
Return True
End If
Return False
End Function
End Class
Class D : Inherits DynamicObject
Public Overrides Function TryGetMember(binder As System.Dynamic.GetMemberBinder, ByRef result As Object) As Boolean
If binder.Name = "Address" Then
result = "addr"
Return True
End If
Return False
End Function
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment