且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实现接口C#

更新时间:2022-05-22 21:48:50

好像您在示例中留下了一条线.我相信实施中的ThePerson行应显示为

It looks like you left a line out in your sample. I believe the ThePerson line in the implementation should read

Person IApplicationPage.ThePerson { get; set; }

这种类型的实现称为显式接口实现.这意味着仅当通过接口类型的引用看到对象时,该成员才可见.

This type of implementation is known as an explicit interface implementation. This means the member will only be viewable when the object is seen through a reference of the interface type.

如果您希望通过具体的类型引用查看该成员,请将其公开并删除显式实现

If you want the member to be viewable through a concrete type reference, make it public and remove the explicit implementation

public Person ThePerson { get; set; }