Update LDM-2018-10-17.md (#2246)

Add the details of a question (Properties with a private accessor) so the resolution makes sense in context.
This commit is contained in:
Neal Gafter 2019-02-19 11:08:20 -08:00 committed by GitHub
parent f3f5c711d6
commit 4e3f2e4ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,6 +75,45 @@ No override keyword in interfaces. This should resolve all listed questions.
#### Properties with a private accessor
We say that private members are not virtual, and the combination of virtual and private is disallowed. But what about a property with a private accessor?
``` c#
interface IA
{
public virtual int P
{
get => 3;
private set => { }
}
}
```
Is this allowed? Is the `set` accessor here `virtual` or not? Can it be overridden where it is accessible? Does the following implicitly implement only the `get` accessor?
``` c#
class C : IA
{
public int P
{
get => 4;
set { }
}
}
```
Is the following presumably an error because IA.P.set isn't virtual and also because it isn't accessible?
``` c#
class C : IA
{
int IA.P
{
get => 4;
set { }
}
}
```
The first example looks valid, while the last does not. This is resolved
analogously to how it already works in C#.