Description
They say there are 4 cases for type pattern matching. But the second and the third seem to me to be identical:
-
expr is an instance of a type that derives from type. In other words, the result of expr can be upcast to an instance of type.
-
expr has a compile-time type that is a base class of type, and expr has a runtime type that is type or is derived from type. The compile-time type of a variable is the variable's type as defined in its declaration. The runtime type of a variable is the type of the instance that is assigned to that variable.
Am I missing something? If there is a very subtle difference, focus should be put on it because this way it's very difficult to spot it.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 3126aaa9-8f5f-04f3-2d75-96477b6273cd
- Version Independent ID: 3f4b3eac-11eb-2dd6-4f27-b24537367288
- Content: is - C# Reference
- Content Source: docs/csharp/language-reference/keywords/is.md
- Product: dotnet-csharp
- Technology: csharp-language-reference
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn
Metadata
Metadata
Assignees
Labels
Type
Projects
Status