ใช้คุณสมบัติ IsFixedSize ของ Hashtable ตรวจสอบว่า Hashtable มีขนาดคงที่หรือไม่
ตัวอย่าง
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
Hashtable ht = new Hashtable();
ht.Add("D01", "Finance"); ht.Add("D02", "HR"); ht.Add("D03", "Operations");
Console.WriteLine("IsFixedSize = " + ht.IsFixedSize);
Console.ReadKey();
}
}
}
ผลลัพธ์
IsFixedSize = False
สร้าง Hashtable เพิ่มสมาชิก แล้วตรวจสอบ IsFixedSize:
Hashtable ht = new Hashtable();
ht.IsFixedSize