I can't get a handle on the syntax. Can anyone give me a simple demo?
views:
212answers:
3
+9
A:
It's been awhile but I think it's just:
Class MyClass : Inherits MyBaseClass : Implements IMyInterface1, IMyInterface2
The : are just so you can do it all on one line. If you don't use them it looks like:
Class MyClass
Inherits MyBaseClass
Implements IMyInterface1, IMyInterface2
Which is confusing if you're looking at a C# example because in that the colon is the inherit operator.
Spencer Ruport
2009-08-06 23:59:02
That's C#, the OP asked for VB.Net
TGnat
2009-08-07 00:04:40
Note my explanation. ;)
Spencer Ruport
2009-08-07 00:05:27
Thanks... Didn't know you could do that.
TGnat
2009-08-07 00:07:55
+1
A:
You cannot inherit implementations from more than one place in VB & C#, afaik. I guess you can do multiple Interface inheritance, though.
RBarryYoung
2009-08-06 23:59:40
Rex M: Yes, that's the language's syntax, but the terminology is "interface inheritance" and implementation" inheritance" (http://en.wikipedia.org/wiki/Interface_inheritance). Or at least it was when I learned it (many years ago).
RBarryYoung
2009-08-07 00:11:08
+3
A:
In VB.NET a class can only inherit from one base class. A VB.Net class can implement multiple interfaces.
Inherits statement:
Public Class thisClass
Inherits anotherClass
End Class
Implementing an interface:
Public Class thisClass
Implements IComparable, IDisposable
End Class
Both Inheriting and implementing in VB.NET:
Public Class thisClass
Inherits anotherClass
Implements IComparable, IDisposable
End Class
Jeff Widmer
2009-08-07 00:01:16
Technically, both of those things are "inheritance", though Microsoft encourages us to use different verbs for them.
RBarryYoung
2009-08-07 00:15:02