Answer Posted / vinay tiwari
//we can perform this job with the help of destructor
using System;
class a
{
public int x;
public a(int b)
{
x=b;
}
public void display()
{
Console.WriteLine(x);
}
~a()
{
Console.Write("destroying object which is
created by a()");
}
}
class b
{
static void Main(string [] args)
{
a ob =new a(5);
ob.display();
}
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is sql transaction in c#?
What are async and await?
What is difference between a type and class?
What are strings in c#?
What is command object in c#?
What is the difference between writeline and write in c#?
Difference between abstract classes and interfaces
Can we override constructor in c#?
How to add a readonly property in c#.net
If a class derives from another class, will the derived class automatically contain all the public, protected, and internal members of the base class?
What is lazy t?
What is strongly typed view?
What is data annotation in c#?
Which config file has all the supported channels/protocol?
Why do I get a security exception when I try to run my c# app?