Thuộc tính IsReadOnly của lớp Hashtable được dùng để lấy giá trị cho biết Hashtable có chỉ đọc hay không.
Ví dụ
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();
}
}
}
Kết quả
IsReadOnly = False
Trên đây chúng ta đã thiết lập Hashtable với ba phần tử.
ht.Add("One", "Amit");
ht.Add("Two", "Aman");
ht.Add("Three", "Raman");
Sau đó, chúng ta kiểm tra sử dụng thuộc tính IsReadOnly.
Console.WriteLine("IsReadOnly = " + ht.IsReadOnly);