What is the IsReadOnly property of Hashtable class in C#?


The IsReadOnly property of Hashtable class is used to get a value indicating whether the Hashtable is read-only.

Example

 Live Demo

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();
      }
   }
}

Output

IsReadOnly = False

Above we have set a Hashtable with three elements.

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

After that, we have checked using the IsReadOnly property.

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

Updated on: 23-Jun-2020

59 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements