Why doesn't the Controls collection provide all of the IEnumerable methods?

前端 未结 4 1592
暖寄归人
暖寄归人 2020-12-29 18:33

I\'m not for sure how the ControlCollection of ASP.Net works, so maybe someone can shed some light on this for me.

I recently discovered the magic that is extension

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 19:14

    In addition to the answers provided by Jon Skeet and Dan Tao, you can use query expression syntax by explicitly providing the type.

    Control myControl = (from Control control in this.Controls
                        where control.ID == "Some ID"
                        select control).SingleOrDefault();
    

提交回复
热议问题