Skip to content

Commit 1384b58

Browse files
authored
clarify how type can declare new static members (#29642)
* clarify how type can declare new static members Fixes #29471 When a type declares a static member with the same signature as an interface it implements, it's not an override. Nor does it hide the method. Instead, it's a unique method declared in a different type. * Move static description to a note.
1 parent bb96321 commit 1384b58

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/csharp/fundamentals/types/interfaces.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Interfaces can contain instance methods, properties, events, indexers, or any co
2828

2929
To implement an interface member, the corresponding member of the implementing class must be public, non-static, and have the same name and signature as the interface member.
3030

31+
> [!NOTE]
32+
> When an interface declares static members, a type implementing that interface may also declare static members with the same signature. Those are distinct and uniquely identified by the type declaring the member. The static member declared in a type *doesn't* override the static member declared in the interface.
33+
3134
A class or struct that implements an interface must provide an implementation for all declared members without a default implementation provide by the interface. However, if a base class implements an interface, any class that's derived from the base class inherits that implementation.
3235

3336
The following example shows an implementation of the <xref:System.IEquatable%601> interface. The implementing class, `Car`, must provide an implementation of the <xref:System.IEquatable%601.Equals%2A> method.

0 commit comments

Comments
 (0)