Share Link
Copied to clipboard
Embed on Your Page
Copied to clipboard
We Stand with Ukraine
SortedList: Capacity by Codebuns Sample Code
---Default capacity is 0; if initialized as an empty sorted list---
0
---Capacity automatically assigned to a list, even if initialized with a single item---
4
---Set the initial capacity of a sorted list by specifying the number in parentheses () when a list is created---
7
---You can set the capacity later in the code, once sorted listed is created---
0
5
---If number of items exceeds the capacity, an exception is thrown ---
Run-time exception (line -1): capacity was less than the current size.
Parameter name: value

Stack Trace:

[System.ArgumentOutOfRangeException: capacity was less than the current size.
Parameter name: value]
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.SortedList`2.set_Capacity(Int32 value)
   at Program.Main()
Last Run: 2:27:27 pm
Compile: 0.078s
Execute: 0s
Memory: 60kb
CPU: 0.062s