Export (0) Print
Expand All

Queue.TrimToSize Method

Sets the capacity to the actual number of elements in the Queue.

[Visual Basic]
Public Overridable Sub TrimToSize()
public virtual void TrimToSize();
public: virtual void TrimToSize();
public function TrimToSize();


Exception Type Condition
NotSupportedException The Queue is read-only.


This method can be used to minimize a list's memory overhead if no new elements will be added to the list.

To completely clear all elements in a list, call the Clear method before calling TrimToSize. Trimming an empty Queue sets the capacity of the Queue to the default capacity, not zero.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Queue Class | Queue Members | System.Collections Namespace | Clear | Count

© 2015 Microsoft