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()
[C#]
public virtual void TrimToSize();
[C++]
public: virtual void TrimToSize();
[JScript]
public function TrimToSize();

Exceptions

Exception Type Condition
NotSupportedException The Queue is read-only.

Remarks

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.

Requirements

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

Show:
© 2014 Microsoft