.net - VB.NET cross compatibility with C# -
i have c# project generic interface
public interface imyfoo<t> { void dosomething(t instance); }
i have c# project interface inherits several imyfoos
public interface imybar : imyfoo<type1>, imyfoo<type2> { ... }
everything works fine in c# land (including scenario below doesn't work in vb).
i have vb .net project references c# library.
i have instance of imybar , try use follows:
dim instance mytype1 = ... dim bar imybar = ... bar.dosomething(instance) ' generates compile error: ' 'dosomething' ambiguous across inherited interfaces 'imyfoo(of mytype1)' , 'imyfoo(of mytype2)'.
what's up? can directcast , works fine...but i'd rather not
directcast(bar, imyfoo(of mytype1)).dosomething(instance)
you're going have cast:
unlike other types, derive single base type, an interface may derive multiple base interfaces. because of this, interface can inherit identically named type member different base interfaces. in such case, multiply-inherited name not available in derived interface, , referring of type members through derived interface causes compile-time error, regardless of signatures or overloading. instead, conflicting type members must referenced through base interface name.
Comments
Post a Comment