How to Dispose a list of objects;Does it Free the Memory [duplicate]
问题 This question already has answers here : Understanding garbage collection in .NET (3 answers) Closed 4 years ago . I have the following class. public class Foo { private string _DirName; private FileStream _MyfileStream; public FileStream MyfileStream { get { return _MyfileStream; } } public string DirName { get { return _DirName; } set { _DirName = value; _MyfileStream = new FileStream(value, FileMode.Create); } } } I have Created a List Of Foo as like the following: List<Foo> FooList = new