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


Hashtable 類的 IsReadOnly 屬性用於獲取一個指示 Hashtable 是否只讀的值。

示例

 實際演示

using System;
using System.Collections;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         Hashtable ht = new Hashtable();
         ht.Add("One", "Amit");
         ht.Add("Two", "Aman");
         ht.Add("Three", "Raman");
         Console.WriteLine("IsReadOnly = " + ht.IsReadOnly);
         Console.ReadKey();
      }
   }
}

輸出

IsReadOnly = False

以上我們在一個 Hashtable 中設定了三個元素

ht.Add("One", "Amit");
ht.Add("Two", "Aman");
ht.Add("Three", "Raman");

然後,我們使用 IsReadOnly 屬性進行了檢查

Console.WriteLine("IsReadOnly = " + ht.IsReadOnly);

更新時間: 2020 年 6 月 23 日

88 次瀏覽

開啟你的 事業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.