Exemplo n.º 1
0
        /// <summary>
        /// Print a dict
        /// </summary>
        /// <param name="dict">Dict to print</param>
        private static void PrintDict(Dict dict)
        {
            var keys = dict.Keys();
              var maxLength = keys.Max(str => str.Length);

              Console.WriteLine("{");

              foreach(var curr in keys)
            Console.WriteLine("  {0,-" +  maxLength.ToString() + "} => {1}", curr, dict.Get(curr));

              Console.WriteLine("}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save the dict to file
        /// </summary>
        /// <param name="dict">Dict</param>
        public void SaveDict(Dict dict)
        {
            Create();

              var keys = dict.Keys();
              for(int idx = 0; idx < keys.Length; idx++)
              {
            var str = (idx == 0 ? "" : "\r\n") + keys[idx] + "\r\n" + dict.Get(keys[idx]);
            var buf = System.Text.Encoding.UTF8.GetBytes(str);
            FileStream.Write(buf, 0, buf.Length);
              }

              Close();
        }