- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check if Hashtable has a fixed size in C#
To check if Hashtable has a fixed size, the code is as follows −
Example
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("Is the Hashtable having fixed size? = "+hash.IsFixedSize); } }
Output
This will produce the following output −
Is the Hashtable having fixed size? = False
Example
Let us see another example −
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 Key and Value pairs..."); foreach(DictionaryEntry entry in hash){ Console.WriteLine("{0} and {1} ", entry.Key, entry.Value); } Console.WriteLine("Is the Hashtable having fixed size? = "+hash.IsFixedSize); } }
Output
This will produce the following output −
Hashtable Key and Value pairs... One and Katie Ten and Tim Five and Harry Three and Barry Seven and Tom Two and John Four and Eight and Andy Nine and I Six and F Is the Hashtable having fixed size? = False
- Related Articles
- Check if ListDictionary has a fixed size in C#
- Check if HybridDictionary has fixed size in C#
- Check if the ArrayList has a fixed size in C#
- Check if a SortedList object has a fixed size in C#
- Check if an Array has fixed size or not in C#
- Check if a Hashtable is equal to another Hashtable in C#
- Check if Hashtable is synchronized C#
- Check if Hashtable is read-only in C#
- Check if the Hashtable contains a specific value in C#
- Check if the Hashtable contains a specific Key in C#
- Check whether a Hashtable contains a specific key or not in C#
- Check if a number has two adjacent set bits in C++
- Check if a Binary Tree (not BST) has duplicate value in C++
- Check If a String Contains All Binary Codes of Size K in C++
- Check if a number has bits in alternate pattern - Set 1 in C++

Advertisements