Thursday, February 23, 2012

use .ContainsKey to check for an existing key in a Dictionary in C#

This told me about this:

if (!Foo.ContainsKey(person.Id.ToString()))

{

   Foo.Add(person.Id.ToString(), person.Name);

}

No comments:

Post a Comment