public long InitializeDictionary(string fileDirectory)
        {
            var    processTime = System.Diagnostics.Stopwatch.StartNew();
            string line;

            _surnames = new List <SurnameData>();
            Encoding     enc = Encoding.GetEncoding("Windows-1250");
            StreamReader sr  = new StreamReader(fileDirectory, enc);

            try
            {
                // Open the text file using a stream reader.
                while ((line = sr.ReadLine()) != null)
                {
                    SurnameData _surnameData = new SurnameData();
                    string[]    readedLine   = line.Split();
                    _surnameData.value   = Int32.Parse(readedLine[0]);
                    _surnameData.surname = readedLine[1];

                    _surnames.Add(_surnameData);
                }
            }
            catch (IOException e)
            {
                Console.Write("Unable to load file");
            }
            catch (FormatException e)
            {
                Console.Write("Invalid file");
            }

            sr.Close();
            processTime.Stop();
            return(processTime.ElapsedMilliseconds);
        }
        private void CreateDictionary(List <Dict> dictionary, int elements)
        {
            foreach (SurnameData data in _surnames)
            {
                if (data.surname.Length < elements)
                {
                    continue;
                }

                string tmpKeyword = data.surname.Substring(0, elements);

                int idx = dictionary.FindIndex(x => x.keyword == tmpKeyword);

                if (idx == -1)
                {
                    Dict tmpDict = new Dict();
                    tmpDict.keyword  = tmpKeyword;
                    tmpDict.surnames = new List <SurnameData>();
                    SurnameData tmpSurnameData = new SurnameData();
                    tmpSurnameData.surname = data.surname;
                    tmpSurnameData.value   = data.value;
                    tmpDict.surnames.Add(tmpSurnameData);
                    dictionary.Add(tmpDict);
                }
                else
                {
                    SurnameData tmpSurnameData = new SurnameData();
                    tmpSurnameData.surname = data.surname;
                    tmpSurnameData.value   = data.value;
                    dictionary[idx].surnames.Add(tmpSurnameData);
                }
            }
        }