Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# return dictionary string/integer from comparison of List and Array

      /// <summary>
        /// Return Dictionary of string/int from comparision of List and Array
        /// </summary>
        /// <param name="colHeaders">List from xml file</param>
        /// <param name="headers">Array from Csv File</param>
        /// <returns></returns>
        public static Dictionary<string, int> GetDictionaryOfListArray(List<string> colHeaders, string[] headers)
        {
            var indexes = new Dictionary<string, int>();
            for (int i = 0; i < headers.Length; i++)
            {
                indexes[headers[i]] = colHeaders.Contains(headers[i]) ? i : -1;
            }

            return indexes;
        }
 
PREVIOUS NEXT
Tagged: #return #dictionary #comparison #List #Array
ADD COMMENT
Topic
Name
7+2 =