相关疑难解决方法(0)

将数组转换为IEnumerable <T>

令我惊讶的是,我得到以下声明:

public static IEnumerable<SomeType> AllEnums 
  => Enum.GetValues(typeof(SomeType));
Run Code Online (Sandbox Code Playgroud)

抱怨无法从System.Array转换为System.Collection.Generic.IEnumerable.我以为后者继承了前者.显然我错了.

因为我不能LINQ它或.ToList它,我不知道如何妥善处理它.我宁愿避免显式转换,因为它是枚举的一堆值,我不认为SomeType -ing它会有很多用处,也不会.

c# arrays ienumerable casting type-conversion

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

arrays ×1

c# ×1

casting ×1

ienumerable ×1

type-conversion ×1