从IList获取数据,而不是IEnumerable(C#)

从IList获取数据,而不是IEnumerable(C#),c#,.net,list,ienumerable,C#,.net,List,Ienumerable,当我得到: public interface Test { IEnumerable<Guid> ModelIds { get; set; } } 但我需要对界面进行更改: public interface Test { IList<Guid> ModelIds { get; set; } } 错误CS0266:无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“System.Collections.Ge

当我得到:

public interface Test
{
    IEnumerable<Guid> ModelIds { get; set; }
}
但我需要对界面进行更改:

public interface Test
{
    IList<Guid> ModelIds { get; set; }
}
错误CS0266:无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“System.Collections.Generic.IList”。存在显式转换(是否缺少强制转换?)


我想问题就在这里

public IEnumerable<Guid> Test
{
   get => m_data.ModelIds;
   set { m_data.ModelIds = value.ToList(); }
}
abc.ModelIds = my_list.Select(x => x.Id);
试一试


Select(x=>x.Id).ToList()
?感谢@dotnetstep的解释
public IList<Guid> Test
abc.ModelIds = my_list.Select(x => x.Id);
public IEnumerable<Guid> Test
{
   get => m_data.ModelIds;
   set { m_data.ModelIds = value.ToList(); }
}
abc.ModelIds = my_list.Select(x => x.Id);
 abc.ModelIds = my_list.Select(x => x.Id).ToList();