I am not quite sure what exactly goes on when I run the code below to add four values (a, b, c ,d ) into my hash table with C#. But I do know that I get wrong answer. after the loop finished, I get 4 ds stored in my hash table . Help me, Please!
Hashtable cirlTmp = new Hashtable();
CycleLink mycylink = new CycleLink();
int i = 0;
for (i = 0; i < 4; i++)
{
mycylink.link_id = i;
mycylink.begine_state = i;//
mycylink.end_state = 1 + i;
mycylink.proscDescrp = (process_descrp)i;
lock (cirlTmp.SyncRoot)
{
cirlTmp.Add(i, mycylink);
}
}
what I get in the cirlTemp is
[3]: link_id=3 begine_state=3 end_state=4 proscDesrp=4;
[2]: link_id=3 begine_state=3 end_state=4 proscDesrp=4;
[1]: link_id=3 begine_state=3 end_state=4 proscDesrp=4;
[0]: link_id=3 begine_state=3 end_state=4 proscDesrp=4;
....... Any hint will be helpful! thanks