gpt4 book ai didi

c# - 如何正确实现继承接口(interface)的具体类 List

转载 作者:行者123 更新时间:2023-11-30 21:31:08 27 4
gpt4 key购买 nike

<分区>

我有一个建议的字典项目架构,如下所示:

public interface IDataDictionary
{
List<IDataDictionaryItem> DictionaryItems { get; set; }
}

字典项为:

public interface IDataDictionaryItem
{
Guid Guild { get; set; }

int SequenceId { get; set; }

string Title { get; set; }

string Value { get; set; }

string Description { get; set; }

string Language { get; set; }

}

当我尝试在这样的具体类中实现它时:

public class HairColorDictionary : IDataDictionary
{
public List<HairColor> DictionaryItems { get; set; }
}

与项目具体实现:

public class HairColor : IDataDictionaryItem
{
public Guid Guild { get; set; }
public int SequenceId { get; set; }
public string Title { get; set; }
public string Value { get; set; }
public string Description { get; set; }
public string Language { get; set; }
}

我收到下面的错误消息,但我似乎无法理解它。谁能告诉我哪里出了问题。

错误信息:

Error CS0738 'HairColorDictionary' does not implement interface member 'IDataDictionary.DictionaryItems'. 'HairColorDictionary.DictionaryItems' cannot implement 'IDataDictionary.DictionaryItems' because it does not have the matching return type of 'List'.

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com