我有两个接口:
public interface I1
{
A MyProperty { get; set; }
}
public interface I2 : I1
{
new B MyProperty { get; set; }
}
在 C# 中,我可以像这样显式实现:
public class C : I1, I2
{
public B MyProperty { get; set; }
A I1.MyProperty { get; set; }
}
不知何故,我必须在 c++/cli 项目中使用这些接口。那么,我如何在 c++/cli 中实现这个呢?
提前致谢。
我自己解决了。它应该是:
public ref class C : I1, I2
{
public:
virtual property B^ MyProperty
{
B^ get() { ... }
void set(B^ value) { ... }
}
protected:
virtual property A^ DummyProperty
{
A^ get() = I1::MyProperty::get { return nullptr; }
void set(A^ value) = I1::MyProperty::set { }
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)