Interfaces

  • Thread starter Thread starter Z D
  • Start date Start date
Z

Z D

Hello,

I have 2 questions regarding the creation/use of interfaces:


1) Is there any way to reverse engineer an existing C# class to create an
interface out of it?

2) How do I specify ENUM's in an interface? The compiler keeps giving errors
when I try to specify an Enum. Is it possible?
If I'm not allowed to specify enum's in an interface, then how would I go
about specifying the interface for a class that have methods which accept
enum's as parameters?

thanks for your help!

-ZD
 
Z D said:
Hello,

I have 2 questions regarding the creation/use of interfaces:


1) Is there any way to reverse engineer an existing C# class to create an
interface out of it?
I'm not sure I understand what you mean by reverse engineer...Some
clarifaction maybe?
2) How do I specify ENUM's in an interface? The compiler keeps giving errors
when I try to specify an Enum. Is it possible?
If I'm not allowed to specify enum's in an interface, then how would I go
about specifying the interface for a class that have methods which accept
enum's as parameters?

Just define the enum and the interface in the same file and you should be
good to go:

Public Enum myenum
one = 1
two
three
End Enum

Public Interface itf
Sub testsub(ByVal classtype As myenum)
End Interface

Public Class c1
Implements itf

Public Sub testsub(ByVal classtype As myenum) Implements itf.testsub

End Sub
End Class


hope that helps..
Imran.
 
Hi Imran,

Thank's for your reply.

By "Reverse Engineering" I meant if I have already created a class, is there
any utility in VS.NET, .NET SDK, etc that would let me generate the
equivalent Interface that I should have used if I wanted to create this this
object by implementing an interface?

Hope this was a little more clear

thanks
-ZD
 
Back
Top