CSharp examples for System.Collections:IDictionary
Add all values from range sequence to src IDictionary. Source is actually modified.
/*<FILE_LICENSE>//from w ww. java2 s . c o m * NFX (.NET Framework Extension) Unistack Library * Copyright 2003-2014 IT Adapter Inc / 2015 Aum Code LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. </FILE_LICENSE>*/ using System.Text; using System.Linq; using System.Collections.Generic; using System; public class Main{ /// <summary> /// Add all values from range sequence to src IDictionary. Source is actually modified. /// </summary> /// <typeparam name="TKey">Type of key</typeparam> /// <typeparam name="TValue">Type of value</typeparam> /// <param name="src">Source IDictionary (where to add range)</param> /// <param name="range">Sequence that should be added to source IDictionary</param> /// <returns>Source with added elements from range (to have ability to chain operations)</returns> public static IDictionary<TKey, TValue> AddRange<TKey, TValue>(this IDictionary<TKey, TValue> src, IEnumerable<KeyValuePair<TKey, TValue>> range) { foreach (KeyValuePair<TKey, TValue> kvp in range) src.Add(kvp.Key, kvp.Value); return src; } }