2
Reply

Argument Exception: "An item with the same key has already b

kris

kris

Mar 17 2015 4:42 PM
1k
I have an application which got hung when i tried to add items to it.

I get a runtime error:
An item with the same key has already been added. 

private class ProductUpdate
{
public int Index = 0;
public string ProductCode;
}
private void UpdateProduct( List<string> account, string userEmail, List<Product> products )
{
Dictionary<string, ProductUpdate> productUpdateDictionary = new Dictionary<string, ProductUpdate>();
for ( int i = 0; i < products.Count; i++ )
{
productUpdateDictionary.Add( products[i].code, new ProductUpdate { Index = i, ProductCode = products[i].code } );
}
}

I don't know how to solve this issue ,any body has any suggestion
Thanks a Lot! 

Answers (2)