Consider registering entrance of new members in a Dictionary
and the time of entrance:
Dictionary<string, DateTime> members = new Dictionary<string, DateTime>();
members.Add("Bob", DateTimeNow);
Thread.Sleep(1000);
members.Add("Joe", DateTimeNow);
Thread.Sleep(1000);
members.Add("Susan", DateTimeNow);
Thread.Sleep(1000);
// Now Joe exits
members.Remove("Joe");
// Then Mike enters
members.Add("Mike", DateTimeNow);
Now the question is where's Mike
location in Dictionary
. Is he added to the end of Dictionary
or he will fill the empty location of Susan
(if we iterate with foreach
or access the Dictionary
via index)? Is the behavior guaranteed for all of the times?