我有这段代码:
private User LoadData(uint userID)
{
User data = null;
DataRow dRow;
DataTable group = new DataTable();
//nonrelevant MySQL queries here.
data = UserFactory.GenerateUser(dRow, group);
while (loadedUserData.Contains(userID))
loadedUserData.Remove(userID);
if (!loadedUserData.ContainsKey(userID))
loadedUserData.Add(userID, data);
return data;
}
我正在获取例如ArgumentException异常:
Item has been already added. Key in the dictionary: '370674' Key added: '370674'
我似乎无法找到错误。我尝试了很多东西,但都没有。正如您所看到的那样,已经检查过,并且不应添加该条目。