Changes

→‎New extension methods: + dictionary.TryAddMany
Line 296: Line 296:  
! method
 
! method
 
! usage
 
! usage
 +
|-
 +
| <samp>Dictionary&lt;TKey, TValue&gt;</samp>
 +
| <samp>TryAddMany</samp>
 +
| Add all the key/value pairs from another dictionary to this one, except for keys that already exist.
 +
 +
For example:
 +
<syntaxhighlight lang="c#">
 +
// before 1.6.9
 +
Dictionary<string, string> fields = new();
 +
if (obj.customFields != null)
 +
{
 +
    foreach ((string key, string value) in obj.customFields)
 +
        fields.TryAdd(key, value);
 +
}
 +
 +
// after 1.6.9
 +
Dictionary<string, string> fields = new();
 +
fields.TryAddMany(obj.customFields);
 +
</syntaxhighlight>
 
|-
 
|-
 
| <samp>string</samp>
 
| <samp>string</samp>
manager
8,549

edits