I have created a variable in C#. Now I want to clear the variables value from the computer memory. Is there any way to do that?
Below is my current attempt at deleting the value of recordLine
, but I can still read the value from memory with DumpIt even though I set the variable to null and call garbage collection.
private void Extract_SLST_VariableLine()
{
StreamReader file = new StreamReader(FilePath + FileName);
while (!file.EndOfStream)
{
string recordLine = null;
if ((recordLine = file.ReadLine()).Trim() != string.Empty)
{
console.writeline(recordLine);
}
recordLine=null;
gc.collect();
}
}