Closed
Description
On the "Partial Classes and Methods - C# Programming Guide" page, it is said that:
Partial methods can be generic. Constraints are put on the defining partial method declaration, and may optionally be repeated on the implementing one.
This is contradictory to what the C# language specification says (and also to the actual behaviour of dotnet
), which is:
Corresponding type parameters in the declarations must have the same constraints (modulo differences in type parameter names).
Generic constraints must be repeated on the implementing declaration, not "optionally", as this code does not compile:
public partial class C {
public partial void M<T>() where T: class;
}
public partial class C {
public partial void M<T>() {
}
}
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 450a248b-ab3f-ac3f-d3a5-b1e74b3355ba
- Version Independent ID: 5e05ac12-7d29-d144-a49a-e54765343c20
- Content: Partial Classes and Methods - C# Programming Guide
- Content Source: docs/csharp/programming-guide/classes-and-structs/partial-classes-and-methods.md
- Product: dotnet-csharp
- Technology: csharp-fundamentals
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn