“Interface not implemented” when Returning Derived Type

前端 未结 12 827
野趣味
野趣味 2020-11-27 21:11

The following code:

public interface ISomeData
{
    IEnumerable Data { get; }
}

public class MyData : ISomeData
{
    private List

        
12条回答
  •  粉色の甜心
    2020-11-27 22:13

    You could implement like this:

    public class MyData : ISomeData
    {
        private List m_MyData = new List();
        public IEnumerable Data { get { return m_MyData; } }
    }
    

提交回复
热议问题