C#言語設計についての小さな質問:))
私がこのようなインターフェースを持っていた場合:
interface IFoo {
int Value { get; set; }
}
C#3.0の自動実装プロパティを使用して、このようなインターフェイスを明示的に実装することができます。
sealed class Foo : IFoo {
int IFoo.Value { get; set; }
}
しかし、インターフェイスにイベントがあった場合:
interface IFoo {
event EventHandler Event;
}
そして、フィールドのようなイベントを使用して明示的に実装しようとしています。
sealed class Foo : IFoo {
event EventHandler IFoo.Event;
}
次のコンパイラエラーが発生します。
error CS0071: An explicit interface implementation of an event must use event accessor syntax
フィールドのようなイベントは、自動実装されたプロパティのある種の二元論だと思います。
だから私の質問は:そのような制限が行われる設計上の理由は何ですか?