enums inside interface ?

What is the way to involve enums in an interface

i know why i can't , but how do i solve this

public interface ICommCallback

{

enum CommEvents // ERROR!

{

Connect,

Disconnect,

Send

}

void handleReceiveCB(byte[] ReceivedData);

void handleEventCB(CommEvents commEvent, bool Res);

}



Answer this question

enums inside interface ?

  • ShivaanKeldon

    VB allows declaring enums (and other types) inside of an interface, but C# does not.

    David Anton
    www.tangiblesoftwaresolutions.com
    Instant C#: VB to C# converter
    Instant VB: C# to VB converter
    Instant C++: C# to C++ converter, VB to C++ converter
    Instant Python: C# to Python converter, VB to Python converter



  • suneelb2b

    Hi rodniko!

    You have to define the enum outside of the interface.

    greets,
    Roland


  • Ramanuj

    Why are you trying to put an enum definition into an interface Interface is kind of a contract.

    You should put your enum outside the interface:

    public interface ICommCallback

    {

    void handleReceiveCB(byte[] ReceivedData);

    void handleEventCB(CommEvents commEvent, bool Res);

    }

    public enum CommEvents

    {

    Connect,

    Disconnect,

    Send

    }


  • enums inside interface ?