what are constructors and destructors



what are constructors and destructors..

Answer / dsr

A constructor is a method, which is called when an object
of a class type is constructed, and it usually used for
initialization. A constructor method has following
characteristics:

It has the same name as class

It has no return type

It does not return any value

Constructors are always public and we use them to
initialize variable.

There is default class constructor without parameter,
provided by C# internally if we did not write any
constructor. when ever compile that class,compiler create
the default constructor(with out parameters).

In the other hand a Destructor is also called a finalizer.
It is just opposite the constructor, it is a method called
when the garbage collector reclaims an object.

Constructors have following characteristics:

The name of a destructor is same as name of class

The destructor declared with a tilde (~).

Destructors are always public and never other than public.

Destructors take no arguments. So, there is only one
destructor per class.

Destructors have no return type.

Is This Answer Correct ?    11 Yes 3 No

Post New Answer

More Dot Net AllOther Interview Questions

How can we perform data binding in atlas?

0 Answers  


Explain write back and write through caches? : .NET Architecture

0 Answers  


What is abstact class? in which scinario we can use abstact class?

4 Answers   iGate,


IS IT Possible to inherit the AJAX page from child class which(child) is inherit from page class.Because i should apply some security in child class

0 Answers   IBM,


Explain how cache is used? : Dot net architecture

0 Answers  






What are the main Tools to develop .Net Application?

0 Answers   HCL,


Explain the Lapsed Listener problem in .net

0 Answers   HCL,


What is the difference between an event and a delegate?

0 Answers  


wild card character in sql ?

2 Answers  


Define a virtual memory? : Dot net architecture

0 Answers  


Explain dma? : .NET Architecture

0 Answers  


what does dot in .net means

1 Answers  


Categories