gpt4 book ai didi

c# - 无法将 List 转换为 IList

转载 作者:太空宇宙 更新时间:2023-11-03 18:06:46 24 4
gpt4 key购买 nike

<分区>

我正在尝试将 List 转换为 IList,但无法转换。编译器只允许我将它转换为 IEnumerable:

//Not allowed, why?
public override IList<ILineEntity> Lines
{
get { return _PharamaLines ?? (_PharamaLines = new List<PharamaLine>()); }
}

//Allowed
public override IEnumerable<ILineEntity> Lines
{
get { return _PharamaLines ?? (_PharamaLines = new List<PharamaLine>()); }
}

PharamaLine类型为 ILineEntity .

Error: Cannot implicitly convert type 'System.Collections.Generic.List<FW.PharamaLine>' to 'System.Collections.Generic.IList<Foundation.Interfaces.ILineEntity>'. An explicit conversion exists (are you missing a cast?)

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