Skip to content

type matching, they talk about 4 cases but aren't the 2nd and the 3rd identical? #22163

Open
@AgostinoX

Description

@AgostinoX

They say there are 4 cases for type pattern matching. But the second and the third seem to me to be identical:

  1. 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.

  2. 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.


Associated WorkItem - 447123

Metadata

Metadata

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.dotnet-csharp/svcin-prThis issue will be closed (fixed) by an active pull request.lang-reference/subsvcokr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Type

No type

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions