In this case I use both as inheritance and interfaces as the latter allows me to refer to quite unrelated classes but in a common way. The method call is usually followed by a series of select case, case isa xyz, case isa vwx etc selections.
I had a slightly different implementation (in attached), where cc wasn’t an Int1, but I think the result is the same. Of course the problem I had was deep in other code and not so simple to extract, but it was continually accessing the wrong overloaded method - or so I thought.
This part of the code works fine - and illustrates that the initial casting is key.
Var c1 As class1 = New subclass1
Var c2 As subClass1 = New subClass1
Var c3 As int1 = New subClass1
Var cc1 As New cc
cc1.doSomething(c1) //param as class1
cc1.doSomething(c2) //param as subClass1
cc1.doSomething(c3) //param as int1
I’m still trying to figure out why my earlier code was giving the wrong answer, possibly the original casting wasn’t as expected though I’m not sure how that would have happened.