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 to create applications by using Visual Studio 2012?

0 Answers   TryTechnicals Pvt Ltd,


What are the important principles of soa (service oriented architecture)?

0 Answers  


What is the use of TPL DATAFLOW?

0 Answers   MCN Solutions,


Explain the difference between l1 and l2 cache? : Dot net architecture

0 Answers  


how can u manage sessions ?

3 Answers   Ness Technologies,






What is a managed code is dim fs as filestreamobject is a managed code? : .NET Architecture

0 Answers  


What is a service contract, operation contract and data contract?

0 Answers  


Can you explain scriptmanager control?

0 Answers  


Explain hard disk? : Dot net architecture

0 Answers  


Let's say I have an existing application written using Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. How would you approach migrating this application to .NET ?

1 Answers  


What are library functions?

0 Answers   DELL,


which tag i need to use manually to bind columns in a datagrid ?

2 Answers  


Categories