Dictionary的简单用法

public static Dictionary Dic_eType = new Dictionary
{
  //["KEY"]="value"
  ["全部"] = "all",
  ["重点人员"] = "black",
  ["陌生人员"] = "stranger",
  ["高频人员"] = "frequent",
};

//调用
var eType = Dic_eType.Keys.Contains(eventType.Text) ? Dic_eType[eventType.Text].ToString() : "all";

Combbox绑定Dictionary的数据源

 Dictionary dic = new Dictionary();
 BindingSource bs = new BindingSource();
 bs.DataSource = dic;
 cbb.DataSource = bs;
 cbb.DisplayMember = "Value";
 cbb.ValueMember = "Key";

你可能感兴趣的:(java,开发语言)