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
@@ -779,13 +779,13 @@ class_body
779
779
;
780
780
```
781
781
782
+
A non-record class shall not have a *class_body* of `;`.
783
+
782
784
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).
783
785
784
786
### 15.2.7 Partial type declarations
785
787
786
-
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)).
787
-
788
-
A non-record class shall not have a *class_body* of `;`.
788
+
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)).
789
789
790
790
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.
791
791
@@ -5757,8 +5757,7 @@ The synthesized `Equals(R?)` returns `true` if and only if each of the following
5757
5757
5758
5758
-`other` is not `null`, and
5759
5759
- 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
5760
-
- 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
5761
-
the value of `EqualityContract == other.EqualityContract`.
5760
+
- 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`.
5762
5761
5763
5762
The record class type includes synthesized `==` and `!=` operators equivalent to operators declared as follows:
5764
5763
@@ -5799,8 +5798,7 @@ A warning shall be issued if one of `Equals(R?)` and `GetHashCode()` is explicit
5799
5798
The synthesized override of `GetHashCode()` returns an `int` result of combining the following values:
5800
5799
5801
5800
- 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
5802
-
- If there is a base record class type, the value of `base.GetHashCode()`; otherwise
5803
-
the value of `System.Collections.Generic.EqualityComparer<System.Type>.Default.GetHashCode(EqualityContract)`.
5801
+
- 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)`.
5804
5802
5805
5803
> *Example*: Consider the following record class types:
0 commit comments