开发者

Is this multiple inheritance? or another syntax for Inherits/Implements like C#?

I am trying to work out why this works

Public Interface IFullService
    Inherits ISerializableObjectLayerService, IVersionService
    <OperationContract()>
    Function StartTrac() As OperationResult(Of Boolean)
    <OperationContract()>
    Function StopTrac() As OperationResult(Of Boolean)
    <OperationContract()>
    Function IsTracRunning() As OperationResult(Of Boolean)
End Interface

An interface doesn't allow you to specify that it "implements" another interface, however in my case I needed to state that I have both interfaces, just by chance I put a comma in and entered the other interface, built and ran my unit tests and it works...

Previously I have been trying to follow a single inheritance tree such as

<ServiceContract()>
Public Interface IFullService
    Inherits IVersionService
    <OperationContract()>
    Function StartTrac() As OperationResult(Of Boolean)
    <OperationContract()>
    Function StopTrac() As OperationResult(Of Boolean)
    <OperationContract()>
    Function IsTracRunning() As OperationResult(Of Boolean)
End Interface

<ServiceContract()>
Public Interface IVersionService
    Inherits ISerializableObjectLayerService
    <OperationContract()>
    Function GetVersionsSince(ByVal VersionNumber As Long, IncludeBetas As Boolean) As OperationResult(Of Core.Setting.MemoryBmsReleaseInfo())
End Interface

As you can see here the IFullService inherits the IVersionService which then inherits the IVersionService. However in my case I needed a way for something to implement IVersionService withou开发者_运维技巧t implementing the ISerializableObjectLayerService which is what lead me to my "working" solution.

Unfortunately I can't work out how to find out what exactly this is doing. I have search through stackoverflow, google, msdn and I can't find an example with Inherits ,

Could some guru please provide some information on what exactly this is accomplishing (would be great if you can provide a MSDN link), as I don't like doing something that I don't understand (as it can lead to problem in the future that you can work out :D)

Hopefully this question isn't too noobish :D


Microsoft docs do mention it:

http://msdn.microsoft.com/en-us/library/ms173156.aspx

An interface itself can inherit from multiple interfaces.

Edit: Another link (All VB, with example), for an early edition of Visual Studio, but the information still applies.

http://msdn.microsoft.com/en-us/library/aa711871%28v=vs.71%29.aspx


Yes, it's multiple inheritance.

... of interfaces.

It means that any IFullService IS A(n) IVersionService. (When you see "any A is also a B", that's what "A inherits from B" means.)

Interface inheritance doesn't have any issues like multiple inheritance does, so MI is allowed. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜