Tuesday, July 14, 2009

How to Dealocate Variables in C#?

In need to know, with the most explanation of the code possible, how to Dealocate/ Erase defined variable in C# after they have been defined.





Example:





int a = 5;





\\ I need to erase that defined variable in RAM

How to Dealocate Variables in C#?
There is no need to explicitely deallocate variables / memory. c# will free up the memory as soon as the variable has gone out of scope.





There are many who believe this system doesn't work and produces leaks - but my experience has shown that these alleged leaks are really objects / variables still in scope - perhaps in less obvious ways.





Try looking into the System.GC (Garbage Collector) class and stuff like GC.Collect - but unless you have a thorough understand of the .Net CLR, let it be managed for you.
Reply:it is automatically erased





by the way u can use keyword "delete" to delete a pointr


No comments:

Post a Comment