遍历Dictionary

public IList<ExamTestInfo> Get(int year)

        {

            IList<ExamTestInfo> list = new List<ExamTestInfo>();

            Dictionary<string, int> t = SelectCodeYear();

            foreach (KeyValuePair<string, int> pair in t)

            {

                if (pair.Value == year)

                {

                    ExamTestInfo info = Select(pair.Key); 



                    list.Add(info);

                }

            }

            return list;

        }

 

 private void InitPlanDropDownList()

        {

            this.ddl_PlanCode.Items.Clear();

            Dictionary<string, int> codes = IExamPlanService.GetCodeYear();

            foreach (KeyValuePair<string, int> pair in codes)

            {

                ListItem item = new ListItem();

                if (pair.Value == DateTime.Now.Year)

                {

                    item.Text = "[本年度]" + pair.Key;

                    if (ddl_PlanCode.SelectedIndex==-1)

                        item.Selected = true;

                }

                else

                {

                    item.Text =pair.Key;

                }

                item.Value = pair.Key;

                this.ddl_PlanCode.Items.Add(item);

            }



        }

 

你可能感兴趣的:(IO)