New answers tagged

-1

As the variables store the memory on the heap If we assign variable to null it will just change the pointer and access the null reference with out deleting the previous variable it applies to even reassigning the variable also. Using IDisposable interface in C# we can remove the variables details from the memory by calling the garbage collector manually. ...


4

Just setting a string to null or calling the GC will not help here. It might delete the reference to the value, but not the value itself. After GC, it may be overwritten, but there is no guarantee that it will happend anytime soon. What you need instead is something aking to a SecureString, that implements a Dispose method and some obfuscation. However, the ...


0

C# handles garbage collection automatically, you can call it explicitly with GC.Collect() however it is considered bad practice. Below is a far more succinct and detailed explanation than I am equipped to give. Alternatively why not just overwrite the variable with a dummy value? You could use null I guess but you would have to be careful of causing an ...


Top 50 recent answers are included