Skip to content

Records with positional parameters cannot be overloaded with a base type #46814

Discussion options

You must be logged in to vote

Records generally disallow implicitly shadowing base members, including types. The following scenario is also disallowed for this reason:

record X1(int A);
// error CS8866: Record member 'X1.A' must be a readable instance property of type 'string' to match positional parameter 'A'.
record X2(string A) : X1(A.Length);

Perhaps if some really compelling scenario came up, the restriction could be eased in your specific scenario, as there isn't really a compelling reason I can think of to access type members or static members via a derived type. e.g. why would you reference the type C.B in your program when you could be more clear by saying A.B?

If we decided that this is something we would ev…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jmarolf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #46814 on September 22, 2020 21:03.