G
Guest
Can someone explain to me why The load method compiles but throws and error
when is called and why do I have write the code with a temp container like
the one in load2 method in order for it to work?
#region Using directives
using System;
using System.Collections;
using System.Text;
#endregion
namespace Testing_Cache
{
public class cls_test
{
private static Hashtable[] obj_Hashtable = new Hashtable[2];
public static void Load()
{
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 10; j++) {
obj_Hashtable.Add(j.ToString(), j);
}
}
}
public static void Load2()
{
Hashtable obj_Temp_Hashtable;
for (int i = 0; i < 2; i++)
{
obj_Temp_Hashtable = new Hashtable();
for (int j = 0; j < 10; j++)
{
obj_Temp_Hashtable.Add(j.ToString(), j);
}
obj_Hashtable = obj_Temp_Hashtable;
}
}
}
}
Thoughts or documentation is appreciated.
Henry
when is called and why do I have write the code with a temp container like
the one in load2 method in order for it to work?
#region Using directives
using System;
using System.Collections;
using System.Text;
#endregion
namespace Testing_Cache
{
public class cls_test
{
private static Hashtable[] obj_Hashtable = new Hashtable[2];
public static void Load()
{
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 10; j++) {
obj_Hashtable.Add(j.ToString(), j);
}
}
}
public static void Load2()
{
Hashtable obj_Temp_Hashtable;
for (int i = 0; i < 2; i++)
{
obj_Temp_Hashtable = new Hashtable();
for (int j = 0; j < 10; j++)
{
obj_Temp_Hashtable.Add(j.ToString(), j);
}
obj_Hashtable = obj_Temp_Hashtable;
}
}
}
}
Thoughts or documentation is appreciated.
Henry