Editorconfig Guide.e

Prefer pattern matching over is with cast check

EditorConfig key: csharp-style-pattern-matching-over-is-with-cast-check

Prefer pattern matching over is with cast check

csharp-style-pattern-matching-over-is-with-cast-check

This option controls whether pattern matching should be preferred over using the is operator followed by an explicit cast.

Default value:

true

Possible values:

  • true
  • false

Examples

true
if (o is string s)
{
  return s;
}
false
if (o is string)
{
  return (string)o;
}