Skip to content

Commit 7052172

Browse files
committed
Option 2 for resolving #1062
This uses two properties instead of a property and a method.
1 parent 19166a6 commit 7052172

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

standard/interfaces.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ For interfaces that are strictly single-inheritance (each interface in the inher
388388
>
389389
> interface ICounter
390390
> {
391-
> void Count(int i);
391+
> int Count { get; set; }
392392
> }
393393
>
394394
> interface IListCounter : IList, ICounter {}
@@ -397,15 +397,14 @@ For interfaces that are strictly single-inheritance (each interface in the inher
397397
> {
398398
> void Test(IListCounter x)
399399
> {
400-
> x.Count(1); // Error
401-
> x.Count = 1; // Error
402-
> ((IList)x).Count = 1; // Ok, invokes IList.Count.set
403-
> ((ICounter)x).Count(1); // Ok, invokes ICounter.Count
400+
> x.Count = 1; // Error
401+
> ((IList)x).Count = 1; // Ok, invokes IList.Count.set
402+
> ((ICounter)x).Count = 1; // Ok, invokes ICounter.Count
404403
> }
405404
> }
406405
> ```
407406
>
408-
> the first two statements cause compile-time errors because the member lookup ([§12.5](expressions.md#125-member-lookup)) of `Count` in `IListCounter` is ambiguous. As illustrated by the example, the ambiguity is resolved by casting `x` to the appropriate base interface type. Such casts have no run-time coststhey merely consist of viewing the instance as a less derived type at compile-time.
407+
> the first statement causes a compile-time error because the member lookup ([§12.5](expressions.md#125-member-lookup)) of `Count` in `IListCounter` is ambiguous. As illustrated by the example, the ambiguity is resolved by casting `x` to the appropriate base interface type. Such casts have no run-time coststhey merely consist of viewing the instance as a less derived type at compile-time.
409408
>
410409
> *end example*
411410
<!-- markdownlint-disable MD028 -->

0 commit comments

Comments
 (0)