【发布时间】:2014-09-13 17:06:20
【问题描述】:
我有两个文件正在编辑以从一组列表中检查。我在其中一个文件的一行上收到以下错误:“无法将列表(字符串)隐式转换为列表(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; }
}
}
【问题讨论】:
-
当
List<string>是定义为List<DiagnosisCode>的属性时,为什么要返回它? -
在第一个 sn-p 中,
DC应该是Claim的属性吗?我想是的。但是在第二个 sn-p 中,我无法分辨public List<string> DC { get; set; }属于哪个类。是不是某个界面? -
@ConradFrix,一旦你说我回去并意识到这是我的一个愚蠢的错误。我什至没有想过要定义的属性。猜猜你有时需要的只是让别人看看你的代码。谢谢。错误现在消失了。 :P
-
testData声明在哪里? -
@Jason9024 如果你修复了它,那么要么删除问题,要么发布答案,这样它就不会挂起。
标签: c# list type-conversion