soa*_*dos 2 c# linq anonymous-function
这是我正在尝试实现的代码:
var query = from line in thedata
orderby () => {
int a = line.IndexOf("Score=\"");
if (line[a + "Score=\"".Length + 1] == '-') {
return
int.Parse(line[a + "Score=\"".Length + 1].ToString()
+ line[a + "Score=\"".Length + 2]);
}
return int.Parse(line[a + "Score=\"".Length + 1].ToString());
}
select line;
Run Code Online (Sandbox Code Playgroud)
thedata字符串列表在哪里.
编译器显示错误orderby(无法推断类型参数).如何重写此函数以解决此错误?作为一个侧面点,在这种情况下有更好的方法来获得负数吗?
查询表达式不支持该语法.
你应该OrderBy直接打电话:
var query = data.OrderBy(line => { ... });
Run Code Online (Sandbox Code Playgroud)