Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Add()

void System.Collections.ListDictionaryInternal.Add ( object key,
object? value )
inline

Implements System.Collections.IDictionary.

Definition at line 301 of file ListDictionaryInternal.cs.

302 {
303 if (key == null)
304 {
305 throw new ArgumentNullException("key", SR.ArgumentNull_Key);
306 }
307 version++;
308 DictionaryNode dictionaryNode = null;
309 for (DictionaryNode next = head; next != null; next = next.next)
310 {
311 if (next.key.Equals(key))
312 {
313 throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate__, next.key, key));
314 }
315 dictionaryNode = next;
316 }
317 DictionaryNode dictionaryNode2 = new DictionaryNode();
318 dictionaryNode2.key = key;
319 dictionaryNode2.value = value;
320 if (dictionaryNode != null)
321 {
322 dictionaryNode.next = dictionaryNode2;
323 }
324 else
325 {
326 head = dictionaryNode2;
327 }
328 count++;
329 }

References System.SR.Argument_AddingDuplicate__, System.SR.ArgumentNull_Key, System.Collections.ListDictionaryInternal.count, System.SR.Format(), System.Collections.ListDictionaryInternal.head, System.key, System.Collections.ListDictionaryInternal.DictionaryNode.next, System.value, and System.Collections.ListDictionaryInternal.version.