DictionaryClass.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace MySystem
  6. {
  7. public sealed class DictionaryClass
  8. {
  9. #region 根据字典key获取字典值
  10. public string getDictionaryNameByKey(Dictionary<string, string> data, string key)
  11. {
  12. if (data.ContainsKey(key))
  13. {
  14. return data[key];
  15. }
  16. return "";
  17. }
  18. public string getDictionaryNameById(Dictionary<int, string> data, int key)
  19. {
  20. if (data.ContainsKey(key))
  21. {
  22. return data[key];
  23. }
  24. return "";
  25. }
  26. public string getDictionaryNamesByKeys(Dictionary<string, string> data, string keys)
  27. {
  28. string result = "";
  29. string[] keylist = keys.Split(',');
  30. foreach (string subkey in keylist)
  31. {
  32. if (data.ContainsKey(subkey))
  33. {
  34. result += data[subkey] + ",";
  35. }
  36. }
  37. return result.TrimEnd(',');
  38. }
  39. #endregion
  40. }
  41. }