网上一般说是没有限制 直到 内存溢出
我反编译了Hashtable.cs
其一个构造函数如下
public Hashtable(int capacity, float loadFactor)
{
if (capacity < 0)
{
throw new ArgumentOutOfRangeException("capacity", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
}
if ((loadFactor < 0.1f) || (loadFactor > 1f))
{
throw new ArgumentOutOfRangeException("loadFactor", Environment.GetResourceString("ArgumentOutOfRange_HashtableLoadFactor", new object[] { 0.1, 1 }));
}
this.loadFactor = 0.72f * loadFactor;
double num = ((float) capacity) / this.loadFactor;
if (num > 2147483647)
{
throw new ArgumentException(Environment.GetResourceString("Arg_HTCapacityOverflow"));
}
int num2 = (num > 11) ? HashHelpers.GetPrime((int) num) : 11;
this.buckets = new bucket[num2];
this.loadsize = (int) (this.loadFactor * num2);
this.isWriterInProgress = false;
}
可以看出capacity <0.72*2147483647*loadFactor (其中loadFactor 在0.1到1之间)
默认的loadFactor 为1f
故一般情况下 capacity < 1546188225.84
--
Be good @ Java & Dotnet.
Like OpenSource FrameWork,New Technique,especially Between different Platform.
“hill”编写:
> 最多能向Hashtable中插入多少个entry?
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1568384