Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dictionary<string, string> dictonary = new Dictionary<string, string>();
- dictonary count = 2
- {[A,22]}
- {[B,40]}
- List<OtherModel> otherModelList = new List<OtherModel>();
- public class OtherModel
- {
- public string Name{ get; set; }
- public intAge{ get; set; }
- }
- foreach (KeyValuePair<string, string> ol in dictonary)
- {
- var otherModel = new OtherModel()
- {
- Name = ol.Key,
- Age = ol.Value
- };
- otherModelList.Add(otherModel);
- }
- var othersObject = JsonConvert.SerializeObject(otherModelList).ToString();
- othersObject = [{"A":22},{"B":40}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement