Hello! The task appeared to save the dictionary, where the values ​​are objects and then read it from a file. Tell me how best to implement it? I read a bunch of guides how objects are serialized, but sheets are used everywhere, but I cannot find a dictionary. Here is the structure of the object and the dictionary itself:

struct show { int[] place; string moviename; } public Dictionary<DateTimeOffset, show> dict = new Dictionary<DateTimeOffset, show>(); 

This is the dictate I need to save and then read back to the same dictionary from the file.



    1 answer 1

    If there is an opportunity to pull an external library, I will recommend Json.net. Here is its documentation.

    string json = @ "{" "key1" ":" "value1" "," "key2" ":" "value2" "}";

    Dictionary <string, string> values ​​= JsonConvert.DeserializeObject <Dictionary <string, string >> (json);

    Console.WriteLine (values.Count);

    Console.WriteLine (values ​​["key1"]);