question

TZacks-2728 avatar image
0 Votes"
TZacks-2728 asked henrihan-8261 commented

Best way to Dispose List<T>

i did this way....is it good approach or not ? i use TrimExcess() is it good practice. please guide me. thanks

 public static void ListDispose<T>(this List<T> _list)
         {
             if (_list != null)
             {
                 _list.Clear();
                 _list.TrimExcess();
                 _list = null;
             }
         }
dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered henrihan-8261 commented

You can find some threads in MSDN forums archives, like :
What List TrimExcess() does and when to use it


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes, mainly good and detailed answers from Tim Roberts

0 Votes 0 ·