One is hashtable. If uint is used as the primary key when the add method is called, int is used to retrieve the content. I think there should be no difference between the two types in hash processing.
One is anonymous delegation. I think there is a problem when passing a local variable. For the value type, it is not a copy of the value, and the change of this value is actually reflected in the delegate call. the following is the test code.
Delegate void print ();
Class Program
{
Static void Main (String [] ARGs)
{
Probdelegate ();
}
Static void probhashtable ()
{
Hashtable T = new hashtable ();
T. Add (uint) 1, "hello ");
Object o = T [1];
Object O2 = T [1u];
// O will get nothing
// O2 will get the problem Value
Console. writeline ("O = {0} O2 = {1}", O, O2 );
}
Static void probdelegate ()
{
Int [] B = new int [] {1, 2, 3 };
Print [] PS = new print [2];
For (INT I = 0; I <2; I ++)
{// When constructing a delegate, the value of I is 0, 1.
// B [2] is used for delegate calls.
PS [I] = delegate {doprint (B [I]);};
}
For (INT I = 0; I <ps. length; I ++)
{
PS [I] ();
}
// The result is 3 3. Not 1 2
}
Static void doprint (int d)
{
Console. writeline (d );
}
}