Doing a Cast Within a LINQ Query

后端 未结 5 1533
借酒劲吻你
借酒劲吻你 2021-02-01 03:51

Is it possible to do a cast within a LINQ query (for the compiler\'s sake)?

The following code isn\'t terrible, but it would be nice to make it into one query:



        
5条回答
  •  太阳男子
    2021-02-01 04:10

    yes you can do the following:

    List tabList = (from t in content.ChildControls
                                where t as TabSection != null
                                select t as TabSection).ToList();
    

提交回复
热议问题