Home All Groups Group Topic Archive Search About

Newbie question: Enum in Interface

Author
9 Jun 2005 10:58 PM
Alejandro Lapeyre
In VB I can define an Enum inside an interface

Public Interface ITest
    Sub a()
    Enum MyEnum
        kk = 1
    End Enum
End Interface

When I try to do the same in C# the complier complains : "myEnum": las
interfaces no pueden declarar tipos.

public interface ITest
{
    void a();
    public enum myEnum
    {
        kk = 1
    }
}

I can view the VB file with Lutz Roeder's .NET Reflector

Can this be done in C# ?
How can VB do this?

Best regards,
Alejandro Lapeyre

Author
10 Jun 2005 1:32 AM
David Anton
No - C# is very limited compared to VB (and J#) regarding what can be
included in interfaces.  Basically, methods, delegates, and properties are
allowed, but not enums, classes, or structs.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

Show quoteHide quote
"Alejandro Lapeyre" wrote:

> In VB I can define an Enum inside an interface
>
> Public Interface ITest
>     Sub a()
>     Enum MyEnum
>         kk = 1
>     End Enum
> End Interface
>
> When I try to do the same in C# the complier complains : "myEnum": las
> interfaces no pueden declarar tipos.
>
> public interface ITest
> {
>     void a();
>     public enum myEnum
>     {
>         kk = 1
>     }
> }
>
> I can view the VB file with Lutz Roeder's .NET Reflector
>
> Can this be done in C# ?
> How can VB do this?
>
> Best regards,
> Alejandro Lapeyre
>
>
>
Are all your drivers up to date? click for free checkup

Author
10 Jun 2005 1:50 AM
Alejandro Lapeyre
Thanks David!

Show quoteHide quote
:-)
Alejandro Lapeyre

"David Anton" <DavidAn***@discussions.microsoft.com> escribió en el mensaje
news:4B01AE79-C100-4895-97A1-3166ECCC0426@microsoft.com...
> No - C# is very limited compared to VB (and J#) regarding what can be
> included in interfaces.  Basically, methods, delegates, and properties are
> allowed, but not enums, classes, or structs.
>
> David Anton
> www.tangiblesoftwaresolutions.com
> Home of the Instant C# VB.NET to C# converter
> and the Instant VB C# to VB.NET converter
>
> "Alejandro Lapeyre" wrote:
>
>> In VB I can define an Enum inside an interface
>>
>> Public Interface ITest
>>     Sub a()
>>     Enum MyEnum
>>         kk = 1
>>     End Enum
>> End Interface
>>
>> When I try to do the same in C# the complier complains : "myEnum": las
>> interfaces no pueden declarar tipos.
>>
>> public interface ITest
>> {
>>     void a();
>>     public enum myEnum
>>     {
>>         kk = 1
>>     }
>> }
>>
>> I can view the VB file with Lutz Roeder's .NET Reflector
>>
>> Can this be done in C# ?
>> How can VB do this?
>>
>> Best regards,
>> Alejandro Lapeyre
>>
>>
>>

Bookmark and Share