Results 1 to 3 of 3

Thread: how to use a method that is defined in an interface

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2024
    Posts
    72

    how to use a method that is defined in an interface

    Hello,

    I have an interface and a method is defined inside it.
    how can i use this method ?
    here is the interface:

    Public Interface ICalculationContext
    Property ContractPolicy As BasePolicy
    Property ContractCarry As CarryOver

    Property PartPolicy As BasePolicy
    Property PartCarry As CarryOver
    Property Ab As ActuarialBasis

    Function GetPivotCategoryValue(category As PivotCategoryTypes) As String
    End Interface

    thanky you in advance

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,678

    Re: how to use a method that is defined in an interface

    It depends on what exactly you mean by "use this method".

    An interface isn't something that directly contains code, it describes required functionality (think of it like a contract).

    Are you trying to use a class that already implements this interface or are you looking at implementing it yourself?

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,664

    Re: how to use a method that is defined in an interface

    You can't use it directly. You have to define a class that implements the interface and that implements the method. Different classes can implement interface members in different ways, which is the whole point. You can call the same method on any class that implements that interface and it will work, but what the method actually does depends on the class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width