KeyValueData.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. public class KeyValueData
  6. {
  7. public string key="";
  8. public string value="";
  9. public KeyValueData() { }
  10. public KeyValueData(string key,string value)
  11. {
  12. this.key = key;
  13. this.value = value;
  14. }
  15. public static Dictionary<string,string> KeyValueDataList2Dictionary(List<KeyValueData> list)
  16. {
  17. Dictionary<string, string> dic = new Dictionary<string, string>();
  18. if (list != null)
  19. {
  20. foreach (var item in list)
  21. {
  22. dic.Add(item.key, item.value);
  23. }
  24. }
  25. return dic;
  26. }
  27. public static List<KeyValueData> Dictionary2KeyValueDataList(Dictionary<string,string> dic)
  28. {
  29. List<KeyValueData> list = new List<KeyValueData>();
  30. if (dic != null)
  31. {
  32. foreach (var item in dic)
  33. {
  34. KeyValueData d = new KeyValueData(item.Key, item.Value);
  35. list.Add(d);
  36. }
  37. }
  38. return list;
  39. }
  40. }