Bumbala
Bumbala

Reputation: 335

c++/cli Explicit implementation of interface overrides

I have two interfaces:

public interface I1
{
    A MyProperty { get; set; }
}

public interface I2 : I1
{
    new B MyProperty { get; set; }
}

In C# I can explicitly implement like this:

public class C : I1, I2
{
    public B MyProperty { get; set; }
    A I1.MyProperty { get; set; }
}

Somehow I have to use these interfaces in a c++/cli project. So, how can I implement this in c++/cli?

Thanks in advance.

Upvotes: 3

Views: 1464

Answers (1)

Bumbala
Bumbala

Reputation: 335

I solved it myself. It should be:

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 { }
     }
 }

Upvotes: 9

Related Questions