double indexValues = 0;
var filterValues = Values as List<double> ?? Values as List<string>;
return (from val in filterValues select indexValues++).ToList();
Run Code Online (Sandbox Code Playgroud)
它说,
Operator '??' cannot be applied to operands of type 'List<double>' and 'List<string>'
Run Code Online (Sandbox Code Playgroud)
这Values是IEnumerable,有人可以帮我解决这个错误吗?
这是null-coalescing运算符.编译器对此代码的投诉原因是左侧和右侧站点操作数类型应该是相同的类型.在您的代码中List<double>,List<string>是不同的类型.
尝试is检查或转换as并检查它是否为空.
| 归档时间: |
|
| 查看次数: |
1526 次 |
| 最近记录: |