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 add list of items in a web application and win application?

0 Answers   Six Sigma,


How Web service create Proxy Using WSDL?

1 Answers  


Is .net easier than java?

0 Answers  


How does .net remoting work?

0 Answers  


what is the need of vss to developer?

1 Answers  






What is this DLL hell problem in dotnet? Can a virtual class be created/can a virtual method be created inside the class?

3 Answers   HCL,


What is gui programming? : .NET Architecture

0 Answers  


How can I write my own .NET host?

0 Answers   HCL,


How do we do authentications using atlas?

0 Answers  


Why should hire you in company

1 Answers   Concentrix,


Hi, this is satish, i have more than 2 years of exp. on Microsoft .Net Technologies like C#, ASP.Net, VB.Net. But i am willing to change my platform into Testing tool. give me best suggestion for me.

2 Answers  


What is the difference between metadata and menifest ?

0 Answers  


Categories