How to fix the size of the Hashtable and find the whether it has fix size or not?

Posted by Vijjendra on Stack Overflow See other posts from Stack Overflow or by Vijjendra
Published on 2010-06-07T09:37:57Z Indexed on 2010/06/07 9:42 UTC
Read the original article Hit count: 549

Filed under:
|
|
|

Hi All, I am trying to fix the size of the Hashtable with following code.

       Hashtable hashtable = new Hashtable(2);

        //Add elements in the Hashtable
        hashtable.Add("A", "Vijendra");
        hashtable.Add("B", "Singh");
        hashtable.Add("C", "Shakya");
        hashtable.Add("D", "Delhi");
        hashtable.Add("E", "Singh");
        hashtable.Add("F", "Shakya");
        hashtable.Add("G", "Delhi");
        hashtable.Add("H", "Singh");
        hashtable.Add("I", "Shakya");
        hashtable.Add("J", "Delhi");

I have fix the size of this Hashtable is 2 but I can add more than 2 elements in this, why this happen, I am doing somthing wrong?

I have tried to find out is this Hashtable have fix size of not with hashtable.IsFixedSize, it always returns false

Please tell me where I am wrong, or there is another way..

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET