I just discovered, quite by accident, that this seems to work:
Public Interface Ix ReadOnly Property TestProp() End Interface Public Interface Iy Property TestProp() End Interface Public Sub TestSub Dim x As Ix = Me.InstantiationNotImportant() Dim y As Iy = CType(x, Iy) End Sub
Maybe I’ve written a bit too much code today, but this doesn’t make sense to me. How is it possible that I can convert one interface to another one that is even slightly different?
Any thoughts?
EDIT: It appears that I was indeed just light-headed from too much coding. After a little sleep, the world makes sense again. 🙂
Like Garry said Instantiation is important because if I do this:
The following won’t work.
it runs but yvar will be null because the cast is not possible, but if you declare test like this:
It will now work, as Test uses both interfaces and casting from the object in xvar to Y is valid.