Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why dispose method is not for string object?

Tags:

.net

dispose

why dispose method is not for string object in c#? As we know Dispose() is the method for dispose the object. But why it is not allows for string object or integer object?

Edited: What does the mean of managed object ?. Please guide me.

like image 439
Red Swan Avatar asked Aug 31 '10 05:08

Red Swan


2 Answers

No, Dispose is the method to dispose resources not managed by the GC. String is just a regular, managed object and will thus be automatically reclaimed by garbage collection.

like image 192
Brian Rasmussen Avatar answered Sep 24 '22 16:09

Brian Rasmussen


Dispose is to release all external resources, string and int are simple data types and have no external resources.

like image 45
Sruly Avatar answered Sep 24 '22 16:09

Sruly