scapegoat17
scapegoat17

Reputation: 5821

Does not implement interface member issues

I have:

public interface ITest
{
    string test { get; set; }
}

And

[DataContract]
public class TestGeneric : ITest
{
    [DataMember]
    public string test;
}

But i keep getting the error: 'TestGeneric' does not implement interface member 'ITest.Test' on TestGeneric in the public class TestGeneric : ITest line of code. Would someone be able to explain why this is?

Upvotes: 4

Views: 6314

Answers (1)

Amir Popovich
Amir Popovich

Reputation: 29836

You have created a field, as you omitted the { get; set; } accessors that make a member a property.

The implementation must match the interface exactly, so add those accessors:

public class TestGeneric : ITest
{
    public string Test { get; set; }
}

Upvotes: 9

Related Questions