How to set list items to null C#?
c#, dispose, memory-leaks
Solution
Suppose panel is you parent control which contains all child control , so loop through all child controls and call dispose method of each...that might resolve your issue
while (panel.Controls.Count > 0)
{
panel.Controls[0].Dispose();
}
Calling clear method just remove your controls from the container control not from the memory so you need to dispose them...
Problem
I have a user control called container in which I am adding other user controls at run time. I want to remove all controls from container, I am doing `container.Controls.Clear()` but my controls are still in memory, how can I make them null ?