R – Can an Interface contain an ENum

asp.netinterfacenetvb.net

Can an Interface contain an Enum?

I am using asp.net 2.0. Suddenly my code started having problems when I added an enum to the interface below. In it, LookUpType is an enum.

Public Interface ILookup
    Property ID() As Int32
    Property Text() As String
    Property Description() As String
    Property Status() As Status
    Property OrderID() As Int32
    ReadOnly Property LookUpType() As LookUpType
End Interface

Best Answer

You're question is a bit ambigious, it sounds like you could be asking either of the following

Can an Interface return a type which is an enum?

Yes. Enum's are not special in any way that prevents them being a return type on an interface

Can an Interface contain an enum definition?

Yes, this is completely legal in VB.Net. It is however not legal in C#

Interface IFoo
    Enum E1
        V1
    End Enum
    Function SomeMethod() As E1
End Interface