CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Location
    Greece
    Posts
    19

    IList-How to use this interface

    I dont Know how can I use Interface In General.
    Please if someone can to send me some simple example
    with e.g IList.Add or something else
    Last edited by gregory82gr; January 4th, 2006 at 06:02 AM.

  2. #2
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: IList-How can I use this interface

    You are not supposed to work with IList interface (uless you really have to).
    Inherit from CollectionBase instead, or implement ICollection.

    Interfaces in general define a contract that a class which inmplements that interface has to follow: The implementing class must implement all methods, properties and events that are in the interface.
    Example:
    Code:
    Public Interface MyInterface
       Event E()
       Sub F(ByVal Value As Integer)
       Property P() As String
    End Interface
    
    Public Class MyClass
        Implements MyInterface
         
         (...) ' Must implement E,F,P
    End Class

  3. #3
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: IList-How can I use this interface

    The Interface
    Code:
    public interface face
    sub eye(..)
    property weep(..) as integer 
    end interface
    2 class implementing the interface
    Class1
    Code:
    public class c1
    
    implements face 
    
    sub eye(..) implements face.eye
    ....
    end sub
    
    public property weep() as integer implements face.weep
    get
    ...
    end get
    set(byval a as integer)
    ...
    end set
    end property
    
    end class
    Class2
    Code:
    public class c2
    implements face 
    
    sub eye(..)as integer implements face.eye
    ....
    end sub
    
    public property weep() as integer implements face.weep
    get
    ...
    end get
    set(byval a as integer)
    ...
    end set
    end property
    
    end class
    testing the interface
    Code:
    private sub form1_load(......
    
    dim c1_1 as new c1
    c1_1.weep=12
    c1_1.eye(3)
    
    dim c2_1 as new c2
    c2_1.weep=4
    c2_1.eye(2)
    
    end sub
    Last edited by aniskhan; January 4th, 2006 at 03:51 PM.

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

Featured