protected void Button2_Click(object sender, EventArgs e)
        {
            List<ShowStuder> list = new List<ShowStuder>();
            list.Add(new ShowStuder("小吴", null));
            list.Add(new ShowStuder("小曾", 23));

            var ShoNave = list.FindAll(s => s.Name == "小曾");
            ShoNave.ForEach(j => Response.Write(j.ToString()));
        }
   

    public class ShowStuder
    {
        public string Name { set; get; }

        public int? Age { set; get; }

        public ShowStuder(string name, int? age)
        {
            this.Name = name;
            this.Age = age;
        }

        public override string ToString()
        {
            if (this.Age.HasValue)
                return "姓名为:" + Name + " 今年有:" + Age + " 岁";
            else
                return "姓名为:" + Name + "今年还没有岁数";
        }

相关文章:

  • 2021-12-04
  • 2021-12-12
  • 2022-12-23
  • 2021-10-08
  • 2021-09-23
  • 2022-01-04
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2021-10-16
  • 2022-01-16
  • 2021-10-13
  • 2021-10-06
  • 2022-01-15
  • 2022-12-23
相关资源
相似解决方案