C# में Hashtable का आकार निश्चित है या नहीं, यह जांचने के लिए IsFixedSize प्रॉपर्टी का उपयोग किया जाता है। यह प्रॉपर्टी एक बूलियन मान लौटाती है। Hashtable का आकार कभी निश्चित नहीं होता, इसलिए यह हमेशा false लौटाता है।
उदाहरण 1
using System;
using System.Collections;
public class Demo {
public static void Main() {
Hashtable hash = new Hashtable(10);
hash.Add("1", "A");
hash.Add("2", "B");
hash.Add("3", "C");
hash.Add("4", "D");
hash.Add("5", "E");
hash.Add("6", "F");
hash.Add("7", "G");
hash.Add("8", "H");
hash.Add("9", "I");
hash.Add("10", "J");
Console.WriteLine("क्या Hashtable का आकार निश्चित है? = " + hash.IsFixedSize);
}
}
आउटपुट
क्या Hashtable का आकार निश्चित है? = False
उदाहरण 2
using System;
using System.Collections;
public class Demo {
public static void Main() {
Hashtable hash = new Hashtable();
hash.Add("One", "Katie");
hash.Add("Two", "John");
hash.Add("Three", "Barry");
hash.Add("Four", "");
hash.Add("Five", "Harry");
hash.Add("Six", "F");
hash.Add("Seven", "Tom");
hash.Add("Eight", "Andy");
hash.Add("Nine", "I");
hash.Add("Ten", "Tim");
Console.WriteLine("Hashtable कुंजी और मान जोड़े...");
foreach (DictionaryEntry entry in hash) {
Console.WriteLine("{0} और {1}", entry.Key, entry.Value);
}
Console.WriteLine("क्या Hashtable का आकार निश्चित है? = " + hash.IsFixedSize);
}
}
आउटपुट
Hashtable कुंजी और मान जोड़े... One और Katie Ten और Tim Five और Harry Three और Barry Seven और Tom Two और John Four और Eight और Andy Nine और I Six और F क्या Hashtable का आकार निश्चित है? = False