C# 列表类型转换错误

C# 列表类型转换错误,c#,list,type-conversion,C#,List,Type Conversion,我有两个文件,我正在编辑以检查列表集。我在其中一个文件的一行中遇到以下错误:“无法将列表(字符串)隐式转换为列表(G.E.RE.DC)”,我似乎不知道如何修复该错误。没有其他任何东西会出现问题 以下是第一组代码: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace G.E.RE { [Metadata("Claim", Metadata

我有两个文件,我正在编辑以检查列表集。我在其中一个文件的一行中遇到以下错误:“无法将列表(字符串)隐式转换为列表(G.E.RE.DC)”,我似乎不知道如何修复该错误。没有其他任何东西会出现问题

以下是第一组代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace G.E.RE
{
    [Metadata("Claim", MetadataType.Object)]

    public class Claim
    {
        private List<string> diagCodes = new List<string>();
    }
    public List<DiagnosisCode> DC
    {
        get
        {
            if (testData != null)
                return testData.DC; //This is the line that shows the error

            return this.DC;
        }
        set
        {
            this.DC = value;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using G.E.D.E.RE;

namespace G.E.RE
{
    public List<string> DC { get; set; }

    public class DC
    {
        public string Code { get; set; }
        public int ICDVersion { get; set; }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
运用系统反思;
名称空间G.E.RE
{
[元数据(“声明”,MetadataType.Object)]
公共类索赔
{
私有列表diagCodes=新列表();
}
公开名单DC
{
得到
{
if(testData!=null)
return testData.DC;//这是显示错误的行
将此文件返回.DC;
}
设置
{
this.DC=值;
}
}
}
下面是第二组代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace G.E.RE
{
    [Metadata("Claim", MetadataType.Object)]

    public class Claim
    {
        private List<string> diagCodes = new List<string>();
    }
    public List<DiagnosisCode> DC
    {
        get
        {
            if (testData != null)
                return testData.DC; //This is the line that shows the error

            return this.DC;
        }
        set
        {
            this.DC = value;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using G.E.D.E.RE;

namespace G.E.RE
{
    public List<string> DC { get; set; }

    public class DC
    {
        public string Code { get; set; }
        public int ICDVersion { get; set; }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用G.E.D.E.RE;
名称空间G.E.RE
{
公共列表DC{get;set;}
公共类DC
{
公共字符串代码{get;set;}
公共int-ICDVersion{get;set;}
}
}

康拉德指出,我的属性定义为List,因此我将其他List更改为相同的类型

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using G.E.D.E.RE;

namespace G.E.RE
{
    public List<DiagnosisCode> DC { get; set; }

    public class DC
    {
        public string Code { get; set; }
        public int ICDVersion { get; set; }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用G.E.D.E.RE;
名称空间G.E.RE
{
公共列表DC{get;set;}
公共类DC
{
公共字符串代码{get;set;}
公共int-ICDVersion{get;set;}
}
}

列表是定义为
列表的属性时,为什么要返回
列表
?在第一个代码段中,
DC
应该是
索赔的属性吗?我想是的。但是在第二个代码片段中,我无法判断公共列表DC{get;set;}
属于哪个类。这是什么界面吗?@ConradFrix,有一次你说我回去后意识到我犯了一个愚蠢的错误。我甚至没有想到财产的定义。我猜有时候你所需要的只是让别人看看你的代码。谢谢错误现在消失了p有
testData
声明吗?@Jason9024如果您修复了它,那么要么删除该问题,要么发布答案,这样它就不会挂起。