public NameObjectCollection Clone() { NameObjectCollection result = new NameObjectCollection(); foreach (DictionaryEntry entry in this) { result.Add((string)entry.Key, entry.Value); } return(result); }
/// <summary> /// Merges two collections. If a key occurs in both collections, the value of the second collection is taken. /// </summary> public static NameObjectCollection Merge(NameObjectCollection first, NameObjectCollection second) { if (first == null && second == null) { return(null); } else if (first == null) { return(second.Clone()); } if (second == null) { return(first.Clone()); } NameObjectCollection result = first.Clone(); foreach (DictionaryEntry entry in second) { result[(string)entry.Key] = entry.Value; } return(result); }