什麼是 C# 中 Hashtable 類的 IsFixedSize 屬性?


使用 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

更新日期: 23-6-2020

75 次瀏覽

開啟你的 職業 生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.