You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/operators/equality-operators.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ That is a case-sensitive ordinal comparison. For more information about string c
65
65
66
66
### Delegate equality
67
67
68
-
Two [delegate](../../programming-guide/delegates/index.md) operands of the same runtime type are equal when both of them are `null` or their invocation lists are of the same length and have equal entries in each position:
68
+
Two [delegate](../../programming-guide/delegates/index.md) operands of the same run-time type are equal when both of them are `null` or their invocation lists are of the same length and have equal entries in each position:
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/operators/patterns.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,8 @@ C# introduced pattern matching in C# 7.0. Since then, each major C# version exte
22
22
23
23
In those constructs, you can match an input expression against any of the following patterns:
24
24
25
-
-[Declaration pattern](#declaration-and-type-patterns): to check the runtime type of an expression and, if a match succeeds, assign an expression result to a declared variable. Introduced in C# 7.0.
26
-
-[Type pattern](#declaration-and-type-patterns): to check the runtime type of an expression. Introduced in C# 9.0.
25
+
-[Declaration pattern](#declaration-and-type-patterns): to check the run-time type of an expression and, if a match succeeds, assign an expression result to a declared variable. Introduced in C# 7.0.
26
+
-[Type pattern](#declaration-and-type-patterns): to check the run-time type of an expression. Introduced in C# 9.0.
27
27
-[Constant pattern](#constant-pattern): to test if an expression result equals a specified constant. Introduced in C# 7.0.
28
28
-[Relational patterns](#relational-patterns): to compare an expression result with a specified constant. Introduced in C# 9.0.
29
29
-[Logical patterns](#logical-patterns): to test if an expression matches a logical combination of patterns. Introduced in C# 9.0.
@@ -38,23 +38,23 @@ For the example of how to use those patterns to build a data-driven algorithm, s
38
38
39
39
## Declaration and type patterns
40
40
41
-
You use declaration and type patterns to check if the runtime type of an expression is compatible with a given type. With a declaration pattern, you can also declare a new local variable. When a declaration pattern matches an expression, that variable is assigned a converted expression result, as the following example shows:
41
+
You use declaration and type patterns to check if the run-time type of an expression is compatible with a given type. With a declaration pattern, you can also declare a new local variable. When a declaration pattern matches an expression, that variable is assigned a converted expression result, as the following example shows:
Beginning with C# 7.0, a *declaration pattern* with type `T` matches an expression when an expression result is non-null and any of the following conditions are true:
46
46
47
-
- The runtime type of an expression result is `T`.
47
+
- The run-time type of an expression result is `T`.
48
48
49
-
- The runtime type of an expression result derives from type `T` or implements interface `T` or another [implicit reference conversion](~/_csharplang/spec/conversions.md#implicit-reference-conversions) exists from it to `T`. The following example demonstrates two cases when this condition is true:
49
+
- The run-time type of an expression result derives from type `T`, implements interface `T`, or another [implicit reference conversion](~/_csharplang/spec/conversions.md#implicit-reference-conversions) exists from it to `T`. The following example demonstrates two cases when this condition is true:
In the preceding example, at the first call to the `GetSourceLabel` method, the first pattern matches an argument value because the argument's runtime type `int[]` derives from the <xref:System.Array> type. At the second call to the `GetSourceLabel` method, the argument's runtime type <xref:System.Collections.Generic.List%601> doesn't derive from the <xref:System.Array> type but implements the <xref:System.Collections.Generic.ICollection%601> interface.
53
+
In the preceding example, at the first call to the `GetSourceLabel` method, the first pattern matches an argument value because the argument's run-time type `int[]` derives from the <xref:System.Array> type. At the second call to the `GetSourceLabel` method, the argument's run-time type <xref:System.Collections.Generic.List%601> doesn't derive from the <xref:System.Array> type but implements the <xref:System.Collections.Generic.ICollection%601> interface.
54
54
55
-
- The runtime type of an expression result is a [nullable value type](../builtin-types/nullable-value-types.md) with the underlying type `T`.
55
+
- The run-time type of an expression result is a [nullable value type](../builtin-types/nullable-value-types.md) with the underlying type `T`.
56
56
57
-
- A [boxing](../../programming-guide/types/boxing-and-unboxing.md#boxing) or [unboxing](../../programming-guide/types/boxing-and-unboxing.md#unboxing) conversion exists from the runtime type of an expression result to type `T`.
57
+
- A [boxing](../../programming-guide/types/boxing-and-unboxing.md#boxing) or [unboxing](../../programming-guide/types/boxing-and-unboxing.md#unboxing) conversion exists from the run-time type of an expression result to type `T`.
58
58
59
59
The following example demonstrates the last two conditions:
60
60
@@ -68,7 +68,7 @@ Beginning with C# 9.0, for that purpose you can use a *type pattern*, as the fol
Like a declaration pattern, a type pattern matches an expression when an expression result is non-null and its runtime type satisfies any of the conditions listed above.
71
+
Like a declaration pattern, a type pattern matches an expression when an expression result is non-null and its run-time type satisfies any of the conditions listed above.
72
72
73
73
For more information, see the [Declaration pattern](~/_csharplang/proposals/csharp-8.0/patterns.md#declaration-pattern) and [Type pattern](~/_csharplang/proposals/csharp-9.0/patterns3.md#type-patterns) sections of the feature proposal notes.
74
74
@@ -150,7 +150,7 @@ Beginning with C# 8.0, you use a *property pattern* to match an expression's pro
150
150
151
151
A property pattern matches an expression when an expression result is non-null and every nested pattern matches the corresponding property or field of the expression result.
152
152
153
-
You can also add a runtime type check and a variable declaration to a property pattern, as the following example shows:
153
+
You can also add a run-time type check and a variable declaration to a property pattern, as the following example shows:
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/operators/type-testing-and-cast.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,14 @@ helpviewer_keywords:
25
25
26
26
You can use the following operators and expressions to perform type checking or type conversion:
27
27
28
-
-[is operator](#is-operator): to check if the runtime type of an expression is compatible with a given type
29
-
-[as operator](#as-operator): to explicitly convert an expression to a given type if its runtime type is compatible with that type
28
+
-[is operator](#is-operator): to check if the run-time type of an expression is compatible with a given type
29
+
-[as operator](#as-operator): to explicitly convert an expression to a given type if its run-time type is compatible with that type
30
30
-[cast expression](#cast-expression): to perform an explicit conversion
31
31
-[typeof operator](#typeof-operator): to obtain the <xref:System.Type?displayProperty=nameWithType> instance for a type
32
32
33
33
## is operator
34
34
35
-
The `is` operator checks if the runtime type of an expression result is compatible with a given type. Beginning with C# 7.0, the `is` operator also tests an expression result against a pattern.
35
+
The `is` operator checks if the run-time type of an expression result is compatible with a given type. Beginning with C# 7.0, the `is` operator also tests an expression result against a pattern.
36
36
37
37
The expression with the type-testing `is` operator has the following form
38
38
@@ -66,7 +66,7 @@ For information about C# conversions, see the [Conversions](~/_csharplang/spec/c
66
66
67
67
### Type testing with pattern matching
68
68
69
-
Beginning with C# 7.0, the `is` operator also tests an expression result against a pattern. The following example shows how to use a [declaration pattern](patterns.md#declaration-and-type-patterns) to check the runtime type of an expression:
69
+
Beginning with C# 7.0, the `is` operator also tests an expression result against a pattern. The following example shows how to use a [declaration pattern](patterns.md#declaration-and-type-patterns) to check the run-time type of an expression:
70
70
71
71
[!code-csharp-interactive[is with declaration pattern](snippets/shared/TypeTestingAndConversionOperators.cs#IsDeclarationPattern)]
72
72
@@ -125,11 +125,11 @@ You can also use the `typeof` operator with unbound generic types. The name of a
An expression cannot be an argument of the `typeof` operator. To get the <xref:System.Type?displayProperty=nameWithType> instance for the runtime type of an expression result, use the <xref:System.Object.GetType%2A?displayProperty=nameWithType> method.
128
+
An expression cannot be an argument of the `typeof` operator. To get the <xref:System.Type?displayProperty=nameWithType> instance for the run-time type of an expression result, use the <xref:System.Object.GetType%2A?displayProperty=nameWithType> method.
129
129
130
130
### Type testing with the `typeof` operator
131
131
132
-
Use the `typeof` operator to check if the runtime type of the expression result exactly matches a given type. The following example demonstrates the difference between type checking performed with the `typeof` operator and the [is operator](#is-operator):
132
+
Use the `typeof` operator to check if the run-time type of the expression result exactly matches a given type. The following example demonstrates the difference between type checking performed with the `typeof` operator and the [is operator](#is-operator):
133
133
134
134
[!code-csharp[typeof vs is](snippets/shared/TypeTestingAndConversionOperators.cs#TypeCheckWithTypeOf)]
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/operators/with-expression.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Available in C# 9.0 and later, a `with` expression produces a copy of its [recor
16
16
17
17
As the preceding example shows, you use [object initializer](../../programming-guide/classes-and-structs/object-and-collection-initializers.md) syntax to specify what members to modify and their new values. In a `with` expression, a left-hand operand must be of a record type.
18
18
19
-
The result of a `with` expression has the same runtime type as the expression's operand, as the following example shows:
19
+
The result of a `with` expression has the same run-time type as the expression's operand, as the following example shows:
0 commit comments