Use pattern matching

Applies to: yesVisual Studio noVisual Studio for Mac noVisual Studio Code

This refactoring applies to:

  • C#

What: Use pattern matching.

When: You want to use the new C# pattern matching capabilities.

Why: This refactoring will make your code more clear and concise.


  1. Place your caret inside the statement.

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

  3. Select Use pattern matching.

    Make class abstract

See also