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: standard/classes.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -778,13 +778,13 @@ class_body
778
778
;
779
779
```
780
780
781
+
A non-record class shall not have a *class_body* of `;`.
782
+
781
783
For a record class, the *class_body*s `{}`, `{};`, and `;` are equivalent. They all indicate that the only members are those synthesized by the compiler (§synth-members).
782
784
783
785
### 15.2.7 Partial type declarations
784
786
785
-
The modifier `partial` is used when defining a class, struct, or interface type in multiple parts. The `partial` modifier is a contextual keyword ([§6.4.4](lexical-structure.md#644-keywords)) and has special meaning immediately before the keywords `class`, `struct`, and `interface`. (A partial type may contain partial method declarations ([§15.6.9](classes.md#1569-partial-methods)).
786
-
787
-
A non-record class shall not have a *class_body* of `;`.
787
+
The modifier `partial` is used when defining a class, struct, or interface type in multiple parts. The `partial` modifier is a contextual keyword ([§6.4.4](lexical-structure.md#644-keywords)) and has special meaning in a *class_declaration*, a *struct_declaration*, or an *interface_declaration*. (A partial type may contain partial method declarations ([§15.6.9](classes.md#1569-partial-methods)).
788
788
789
789
Each part of a ***partial type*** declaration shall include a `partial` modifier and shall be declared in the same namespace or containing type as the other parts. The `partial` modifier indicates that additional parts of the type declaration might exist elsewhere, but the existence of such additional parts is not a requirement; it is valid for the only declaration of a type to include the `partial` modifier. It is valid for only one declaration of a partial type to include the base class or implemented interfaces. However, all declarations of a base class or implemented interfaces shall match, including the nullability of any specified type arguments.
790
790
@@ -5754,8 +5754,7 @@ The synthesized `Equals(R?)` returns `true` if and only if each of the following
5754
5754
5755
5755
-`other` is not `null`, and
5756
5756
- For each instance field `fieldN` in the record class type that is not inherited, the value of `System.Collections.Generic.EqualityComparer<TN>.Default.Equals(fieldN, other.fieldN)` where `TN` is the field type, and
5757
-
- If there is a base record class type, the value of `base.Equals(other)` (a non-virtual call to `public virtual bool Equals(Base? other)`); otherwise
5758
-
the value of `EqualityContract == other.EqualityContract`.
5757
+
- If there is a base record class type, the value of `base.Equals(other)` (a non-virtual call to `public virtual bool Equals(Base? other)`); otherwise the value of `EqualityContract == other.EqualityContract`.
5759
5758
5760
5759
The record class type includes synthesized `==` and `!=` operators equivalent to operators declared as follows:
5761
5760
@@ -5796,8 +5795,7 @@ A warning shall be issued if one of `Equals(R?)` and `GetHashCode()` is explicit
5796
5795
The synthesized override of `GetHashCode()` returns an `int` result of combining the following values:
5797
5796
5798
5797
- For each instance field `fieldN` in the record class type that is not inherited, the value of `System.Collections.Generic.EqualityComparer<TN>.Default.GetHashCode(fieldN)` where `TN` is the field type, and
5799
-
- If there is a base record class type, the value of `base.GetHashCode()`; otherwise
5800
-
the value of `System.Collections.Generic.EqualityComparer<System.Type>.Default.GetHashCode(EqualityContract)`.
5798
+
- If there is a base record class type, the value of `base.GetHashCode()`; otherwise the value of `System.Collections.Generic.EqualityComparer<System.Type>.Default.GetHashCode(EqualityContract)`.
5801
5799
5802
5800
> *Example*: Consider the following record class types:
0 commit comments