คุณสมบัติ Capacity ในคลาส SortedList แสดงขนาดสูงสุดของ SortedList
ค่า Capacity เริ่มต้นของ SortedList คือ 16
ตัวอย่าง
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
SortedList s = new SortedList();
s.Add("S1", "Maths");
s.Add("S2", "Science");
s.Add("S3", "English");
s.Add("S4", "Economics");
Console.WriteLine("Capacity = " + s.Capacity);
}
}
}
ผลลัพธ์
Capacity = 16
ข้างต้นเราเพิ่มสมาชิก 4 ตัว แต่ Capacity ยังคงเป็น 16 (ค่าเริ่มต้น)