Skip to content

Instantly share code, notes, and snippets.

@joao-r-reis
Last active October 31, 2020 16:46
Show Gist options
  • Save joao-r-reis/ba81aea1812b7ff74e54627e864e8be5 to your computer and use it in GitHub Desktop.
Save joao-r-reis/ba81aea1812b7ff74e54627e864e8be5 to your computer and use it in GitHub Desktop.
InitializeFromCollection.cs
private void InitializeFromCollection(IEnumerable<KeyValuePair<TKey, TValue>> collection)
{
TValue dummy;
foreach (KeyValuePair<TKey, TValue> pair in collection)
{
if (pair.Key == null) throw new ArgumentNullException("key");
if (!TryAddInternal(pair.Key, pair.Value, false, false, out dummy))
{
throw new ArgumentException(GetResource("ConcurrentDictionary_SourceContainsDuplicateKeys"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment