using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MySystem { public sealed class DictionaryClass { #region 根据字典key获取字典值 public string getDictionaryNameByKey(Dictionary data, string key) { if (data.ContainsKey(key)) { return data[key]; } return ""; } public string getDictionaryNameById(Dictionary data, int key) { if (data.ContainsKey(key)) { return data[key]; } return ""; } public string getDictionaryNamesByKeys(Dictionary data, string keys) { string result = ""; string[] keylist = keys.Split(','); foreach (string subkey in keylist) { if (data.ContainsKey(subkey)) { result += data[subkey] + ","; } } return result.TrimEnd(','); } #endregion } }