Interfaces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Z D

    Interfaces

    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


  • Imran Koradia

    #2
    Re: Interfaces


    "Z D" <nospam@nospam. com> wrote in message
    news:eD05KwFvEH A.2172@TK2MSFTN GP14.phx.gbl...[color=blue]
    > 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?[/color]
    I'm not sure I understand what you mean by reverse engineer...Some
    clarifaction maybe?
    [color=blue]
    >
    > 2) How do I specify ENUM's in an interface? The compiler keeps giving[/color]
    errors[color=blue]
    > 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?[/color]

    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.


    Comment

    • Z D

      #3
      Re: Interfaces

      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



      "Imran Koradia" <nospam@microso ft.com> wrote in message
      news:%23gTESAGv EHA.3272@TK2MSF TNGP12.phx.gbl. ..[color=blue]
      >
      > "Z D" <nospam@nospam. com> wrote in message
      > news:eD05KwFvEH A.2172@TK2MSFTN GP14.phx.gbl...[color=green]
      >> 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?[/color]
      > I'm not sure I understand what you mean by reverse engineer...Some
      > clarifaction maybe?
      >[color=green]
      >>
      >> 2) How do I specify ENUM's in an interface? The compiler keeps giving[/color]
      > errors[color=green]
      >> 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?[/color]
      >
      > 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.
      >
      >[/color]


      Comment

      Working...