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

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

1 Answers  


What is application frame host?

1 Answers  


Why the config file might not be writable

1 Answers  


What is .net mobile images control. : Microsoft dot net mobile

1 Answers  


Explain the race around condition? : .NET Architecture How can it be overcome? : .NET Architecture

1 Answers  


Differences between VS 2005, 2008 and 2010 ?

1 Answers   HCL,


What is difference between .net and visual studio?

1 Answers  


I am working with asp.net 2005 and Crystal report 10. I have an image field on my dataset to show on Crystal report.And the image is shows dynamically from database in image field of CR. The image field is showing well on my Crystal report on its first page with all other data but when i click to open second page of CR,it does not show any data on that.I found that this is because of adding the image field on crystal report. Because when i remove the image field from the CR then it will run both the pages of CR. I am using the Page Load event to bind CR data with Database. And i have already check with the Init event to bind CR , but it still not shows the data on second page when i use image field on that. Please give solution for that.....

1 Answers  


What is Ienumerable

1 Answers  


What is the difference between .net mobile pages and ordinary .net web page? : Microsoft dot net mobile

1 Answers  


server.transfer limitation ?

1 Answers  


Explain the difference between state server and sqlserver : Dot net architecture

1 Answers  


Categories