Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does not implement interface member issues

Tags:

c#

interface

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?

like image 503
scapegoat17 Avatar asked Feb 11 '23 05:02

scapegoat17


1 Answers

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; }
}
like image 152
Amir Popovich Avatar answered Feb 13 '23 21:02

Amir Popovich