Count is set to 0, and references to other objects from elements of the collection are also released.
Capacity remains unchanged. To reset the capacity of the List(T), call the TrimExcess method or set the Capacity property directly. Decreasing the capacity reallocates memory and copies all the elements in the List(T). Trimming an empty List(T) sets the capacity of the List(T) to the default capacity.
This method is an O(n) operation, where n is Count.
The following example demonstrates the Clear method and various other properties and methods of the List(T) generic class. The Clear method is used at the end of the program, to remove all items from the list, and the Capacity and Count properties are then displayed.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)