How to dispose List

Jun 30 2011 12:47 AM

Hi experts,

I am having List<User> object. How I can dispose the list ?

For example,

List<User> usersCollection =new List<User>();

User user1 = new User();
User user2 = new User()

userCollection.Add(user1);
userCollection.Add(user2);

if I set , userCollection = null; what will happen?

foreach(User user in userCollection)
{
    user = null;
}

Which one is best?





Answers (4)