Advertisement
Aborigenius

DeserializeString

Aug 23rd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DeserializeString
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             SortedDictionary<int, char> deserialized = new SortedDictionary<int, char>();
  14.             string input = Console.ReadLine();
  15.             while (input != "end")
  16.             {
  17.                 string[] tokens = input.Split(':');
  18.                 char @char = tokens[0][0];
  19.                 int[] numbers = tokens[1].Split('/').Select(int.Parse).ToArray();
  20.  
  21.                 foreach (int index in numbers)
  22.                 {
  23.                     deserialized[index] = @char;
  24.                 }
  25.                 input = Console.ReadLine();
  26.  
  27.             }
  28.  
  29.             Console.WriteLine(deserialized.Values.ToArray());
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement