T
Tomasz Jastrzebski
Hello,
Below are to equivalent(?) pieces of C# and VB.Net code
While the C# version compiles with no warning, the VB.Net version does not
compile due to the compiler error BC30149: Class 'c2' must implement 'Sub
m1()' for interface 'i1'.
Does it mean that in VB interface must be implemented, even if it is already
non-explicitly implemented in the base class c1?
How to make this VB code compile *without altering the c1 class* ? - that is
the constraint!
I can not get it compile in VB, while in C# it is just a piece of cake.
Motivation: I want to access base class methods by interface specified in a
derived class.
As strange as it sounds, in C# it works just as expected - test yourself: i1
c = new c2(); c.m1();
Thank you,
Tomasz
// C# version
class c1 {
public virtual void m1() {
}
}
class c2 : c1, i1 {
}
public interface i1 {
void m1();
}
' VB version
Class c1
Public Overridable Sub m1()
End Sub
End Class
Class c2
Inherits c1
Implements i1
End Class
Public Interface i1
Sub m1()
End Interface
Below are to equivalent(?) pieces of C# and VB.Net code
While the C# version compiles with no warning, the VB.Net version does not
compile due to the compiler error BC30149: Class 'c2' must implement 'Sub
m1()' for interface 'i1'.
Does it mean that in VB interface must be implemented, even if it is already
non-explicitly implemented in the base class c1?
How to make this VB code compile *without altering the c1 class* ? - that is
the constraint!
I can not get it compile in VB, while in C# it is just a piece of cake.
Motivation: I want to access base class methods by interface specified in a
derived class.
As strange as it sounds, in C# it works just as expected - test yourself: i1
c = new c2(); c.m1();
Thank you,
Tomasz
// C# version
class c1 {
public virtual void m1() {
}
}
class c2 : c1, i1 {
}
public interface i1 {
void m1();
}
' VB version
Class c1
Public Overridable Sub m1()
End Sub
End Class
Class c2
Inherits c1
Implements i1
End Class
Public Interface i1
Sub m1()
End Interface