calling destructor of base class without calling destructor of derived class in c#  ,.net

Posted on 2009-07-06
Last Modified: 2012-05-07
can we call a destructor of base class without calling destructor of derived class
using System;
class A
 public A()
  Console.WriteLine("Creating A");
  Console.WriteLine("Destroying A");
class B:A
 public B()
  Console.WriteLine("Creating B");
  Console.WriteLine("Destroying B");
class C:B
 public C()
  Console.WriteLine("Creating C");
  Console.WriteLine("Destroying C");
class App
 public static void Main()
  C c=new C();
  Console.WriteLine("Object Created ");
  Console.WriteLine("Press enter to Destroy it");

Open in new window

Question by:Saini_Vikas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 18

Accepted Solution

Richard Lee earned 50 total points
ID: 24787799
Calling the destructor of a derived class without calling the destructor of the base class would be incorrect. If a class is built from another house if you destroy it then everything should be destroyed.

If you want another behaviour then you need to consider other option of Object Oriented programming such as Aggregation or Composition.

Author Closing Comment

ID: 31618561
Hi ,
Please providesolution  with some satisfactory answer.
LVL 18

Expert Comment

by:Richard Lee
ID: 24796110
50 points do not warrant that. Please ask the question and provide the person answering some incentive,

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question