Answers for "how to create class from dictionary in c#"

C#
0

c# object to dictionary

public static Dictionary<string, TValue> ToDictionary<TValue>(object obj)
{       
    var json = JsonConvert.SerializeObject(obj);
    var dictionary = JsonConvert.DeserializeObject<Dictionary<string, TValue>>(json);   
    return dictionary;
}
Posted by: Guest on November-10-2021
0

c# dictionary with dictionary as value

var collection = new Dictionary<string, Dictionary<string, int>>();
collection.Add("some key", new Dictionary<string, int>());
collection["some key"].Add("inner key", 0);
Posted by: Guest on October-19-2021

Code answers related to "how to create class from dictionary in c#"

C# Answers by Framework

Browse Popular Code Answers by Language