हैशटेबल वर्ग की IsReadOnly संपत्ति का उपयोग यह इंगित करने के लिए किया जाता है कि हैशटेबल केवल पढ़ने के लिए है या नहीं।
उदाहरण
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
ऊपर हमने तीन तत्वों के साथ एक हैशटेबल सेट किया है।
ht.Add("One", "Amit");
ht.Add("Two", "Aman");
ht.Add("Three", "Raman"); उसके बाद, हमने IsReadOnly प्रॉपर्टी का उपयोग करके जाँच की है।
Console.WriteLine("IsReadOnly = " + ht.IsReadOnly);