I am learning C#.
If I first make a variable to hold a list.
List<int> mylist = new List<int>();
Say I did some work with the list, now I want to clear the list to use it for something else. so I do one of the following:
Method 1:
mylist.Clear();
Method 2:
mylist = new List<int>();
The purpose is just to empty all value from the list to reuse the list.
Is there any side effect with using method2. Should I favor one method to the next.
I also found a similar question, Using the "clear" method vs. New Object I will let other readers decide what's best for their own use case. So I won't pick a correct answer.