Doing a Cast Within a LINQ Query

后端 未结 5 1535
借酒劲吻你
借酒劲吻你 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:21

    And here's the query method form.

    List parentLineList =
      content.ChildControls.OfType()
        .SelectMany(t => t.ChildControls.OfType())
        .SelectMany(p => p.ChildControls.OfType())
        .ToList();
    

提交回复
热议问题