SystemIO[] s = Enum.GetNames(typeof(SystemIO)).Cast<SystemIO>().ToArray();
我想将string[]
投射到SystemIO[]
。
我收到以下错误:
跟踪:位于System.Linq.Enumerable.d__97`1.MoveNext()
在System.Linq.Buffer`1..ctor(IEnumerable`1源)处
在System.Linq.Enumerable.ToArray [TSource](IEnumerable`1源)
在TestCase.TestCaseGeneral.AllIos()
为什么我不能这样投射?
答案 0 :(得分:3)
如果要获取值,请放std::span
:
#include <span>
// or:
// #include <gsl/span>
int main() {
// ... etc. ...
{
size_t size = 10e5;
auto uptr { std::make_unique<double[]>(size) };
do_stuff_with_the_doubles(std::span<int> my_span { uptr.get(), size });
}
// ... etc. ...
}
如果要名称更改Enum.GetValues
类型(名称为SystemIO[] s = Enum
.GetValues(typeof(SystemIO))
.Cast<SystemIO>()
.ToArray();
s):
s