Results 1 to 11 of 11

Thread: [2.0] Abstract class must implement interface?

Threaded View

  1. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Abstract class must implement interface?

    It makes complete sense. If a class implements an interface then it promises to implement every member of that interface. Even if you can't create an instance of ClassA directly you can still have instances of that class. Extending the example above, you can do this:
    Code:
    ClassB obj1 = new ClassB();
    
    obj1.MethodB();
    
    ClassA obj2 = (ClassA)obj1;
    
    obj2.MethodB(); // ***
    
    InterfaceA obj3 = (InterfaceA)obj2;
    
    obj3.MethodB();
    If you were allowed to do as you want and not provide an implementation of MethodB in ClassA, the line I've marked with the asterisks would be illegal because ClassA would have no MethodB. Now that wouldn't make sense.
    Last edited by jmcilhinney; Aug 14th, 2006 at 02:45 AM.
    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