Ejemplo n.º 1
0
        /// <summary>
        /// Creates a Dictionary from a list of key value pair lists.
        /// </summary>
        /// <param name="keyValuePairs">A list of paired lists representing Keys and Values.</param>
        /// <returns name="Dictionary">A new dictionary object.</returns>
        public static Dictionary ByKeyValuePairs(c.List<c.List<System.Object>> keyValuePairs)
        {
            c.Dictionary<string, System.Object> dict = new c.Dictionary<string, System.Object>();

            foreach (c.List<System.Object> pair in keyValuePairs)
            {
                    dict.Add((string)pair[0], pair[1]);
            }

            return new Dictionary(dict);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a Dictionary made of key value pairs.
        /// </summary>
        /// <param name="keys">Keys to be used in the dictionary.</param>
        /// <param name="values">Values in the dictionary.</param>
        /// <returns name="Dictionary">A new dictionary object.</returns>
        public static Dictionary ByKeysValues (c.List<string> keys, c.List<System.Object> values)
        {
            c.Dictionary<string, System.Object> dict = new c.Dictionary<string, System.Object>();
            
            int i = 0;
            int vLength = values.Count;
            foreach (string key in keys)
            {
                if (i < vLength)
                {
                    dict.Add(key, values[i]);
                }
                i++;
            }

            return new Dictionary(dict);
        }