Edit

Share via


拳拳爱国心 香港福建社团联会2016年度会务纪实

百度 所以说在这种情况下从比赛开始的那一刻两队就打非常凶,虽然北京打出了一个非常好的开局并且一度把比分的优势给扩大到接近15分,但是在进入下半场之后辽宁便吹起了反扑的号角最终在客场以以75:72击败北京队,大比分3:1挺进4强。

This refactoring applies to:

  • C#

What: Refactors instances of SomeEnumerableType.Where(<LambdaExpression>).Single() to SomeEnumerable.Single(<LambdaExpression>) for Enumerable.Single() as well as the following Enumerable methods: SingleOrDefault(), Last(), LastOrDefault(), Any(), Count(), First(), and FirstOrDefault().

When: All instances where the method calls Single(), SingleOrDefault(), and so on, doesn't have any arguments and is preceded by a Where() expression. The input to the Where() expression cannot be constructed as an expression tree.

Why: Removing the unnecessary call to the Enumerable for the .Where() method improves readability and in some cases performance, see remarks.

How-to

  1. Place your cursor within the SomeEnumerableType.Where(<LambdaExpression>).Single() instance in visual studio.

  2. Press Ctrl+. to trigger the Quick Actions and Refactorings menu.

  3. Select Simplify LINQ expression

    Convert typeof to nameof

Remarks

In some cases this refactoring may reduce performance. LINQ operations on List<T> and T[] are not optimized in this case and result in worse performance.

See also