C# 中 Hashtable 类的 IsFixedSize 属性是什么?

csharpprogrammingserver side programming更新于 2025/10/12 2:07:17

使用 Hashtable 类的 isFixedSize 属性可以获取指示 Hashtable 是否具有固定大小的值。

以下示例展示了如何使用 IsFixedSize 属性。

示例

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 集合。

Hashtable ht = new Hashtable();

添加元素后,我们使用 isFixedSize 属性检查它是否具有固定大小。

ht.IsFixedSize

相关文章