Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Dictionary<string, string> dictonary = new Dictionary<string, string>();
  2.  
  3. dictonary count = 2
  4.  
  5. {[A,22]}
  6. {[B,40]}
  7.  
  8. List<OtherModel> otherModelList = new List<OtherModel>();
  9.  
  10. public class OtherModel
  11. {
  12. public string Name{ get; set; }
  13. public intAge{ get; set; }
  14. }
  15.  
  16. foreach (KeyValuePair<string, string> ol in dictonary)
  17. {
  18. var otherModel = new OtherModel()
  19. {
  20. Name = ol.Key,
  21. Age = ol.Value
  22. };
  23. otherModelList.Add(otherModel);
  24. }
  25.  
  26. var othersObject = JsonConvert.SerializeObject(otherModelList).ToString();
  27. othersObject = [{"A":22},{"B":40}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement