Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7587309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:38:30+00:00 2026-05-30T19:38:30+00:00

Ok I derive a type B from a base class A . A implements

  • 0

Ok I derive a type B from a base class A.
A implements IDisposable explicit but I have to do additional cleanup in B, so I implement IDisposable in B:

interface IDisposable with
    member i.Dispose() =
        // ... additional work
        base.Dispose() // <- want to do but cannot

Question is: how to access the Dispose-method from base?

(base :> IDisposable).Dispose()

yields compiler error: Unexpected symbol ':>' in expression. Expected '.' or other token.

Doing something like

(i :> IDisposable).Dispose()

of course yields a StackOverflowException on runtime – so how can I do this? Sorry but never encountered something like this before…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:38:31+00:00Added an answer on May 30, 2026 at 7:38 pm

    You’re probably better off putting your clean-up logic in a virtual method and implementing IDisposable only once.

    type A() =
      abstract Close : unit -> unit
      default __.Close() =
        printfn "Cleaning up A"
      interface System.IDisposable with
        member this.Dispose() = this.Close()
    
    type B() =
      inherit A()
      override __.Close() = 
        printfn "Cleaning up B"
        base.Close()
    

    Since there’s no protected access modifier, you can use a signature file to make Close non-public (or mark it internal).

    The base keyword can only be used for member access, not standalone. That’s why base :> IDisposable doesn’t work.

    Looking in Reflector, Dispose only calls the public Close method. So you could re-implement IDisposable and call base.Close() instead.

    You could have this same scenario in C#. Inheritable classes that implement IDisposable should provide a way for subclasses to “plug in” to disposal. This is usually done by providing a protected virtual Dispose(disposing) overload that’s called from Dispose(). For whatever reason, DuplexClientBase doesn’t follow this convention. Perhaps it was deemed unnecessary given that Dispose merely forwards to Close.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class DockedToolWindow : Form, and many classes that derive from
I have a base class and several concrete classes that derive from it. Lets
I have a generic abstract base class from which I would like to derive
the following code specifies a type MyBase64Binary which is derived from a base class
I have an abstract base class and derived class: type TInterfaceMethod = class public
I have a simple base entity type called EntityBase that implements IEquatable<EntityBase>. I've used
I have a base class, SpecialClass . Lots of other classes inherit from it,
I have base-class Base from which is derived Derived1 , Derived2 and Derived3 .
In every form we derive from FormBaseControl , we have the following code. I'm
In my game I have a base class of Loot which has methods universal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.