Do Structures have destructors?

Posted by Rajendra.prasad under C# on 4/18/2010 | Views : 2787 | Status : [Member] | Replies : 6
Hi All,
Do Structures have destructors?

Regards,
Rajendra




Responses

Posted by: Vuyiswamb on: 4/19/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
no use the Finally Block to do the cleanup look at this

http://www.codeproject.com/KB/cs/structs_in_csharp.aspx

Thank you for posting at Dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenmanam on: 4/19/2010 [Member] Starter

Up
0
Down
structs

does not have structs, so what's the reason to add it to C#? The basic reason is the ability to create types with value semantics, which, if properly used, leads to better performance in a managed environment.

To substantiate, unlike Java, .NET supports the notion of value types and reference types (in Java, you can define only reference types). Instances of reference types get allocated in the managed heap and are garbage collected when there are no outstanding references to them. Instances of value types, on the other hand, are allocated in the stack, and hence allocated memory is reclaimed as soon as their scope ends. And of course, value types get passed by value (duh!), and reference types by reference. All C# primitive data types, except for System.String, are value types.

NaveenKumar

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Syedshakeer on: 4/19/2010 [Member] Starter

Up
0
Down
Struct doesn't have destructors

Syed Shakeer Hussain

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 4/20/2010 [Member] Bronze

Up
0
Down


Structures Do not have destructors , Structures are of value types and are allocated on stack

Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bunty_18 on: 4/21/2010 [Member] Starter

Up
0
Down
No.

Structures don't have destructors.

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/14/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
hey Sivakumari stop what you are doing. i will remove all the messages you are posting here.

Thank you for posting at Dotnetfunda
[Administrator]

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response