注意_src继承IQueryable<U>和V继承new();
我写了以下语句,没有语法错误.
IQueryable<V> a = from s in _src where (s.Right - 1 == s.Left) select new V();
Run Code Online (Sandbox Code Playgroud)
但如果我按如下方式重写它,Visual Studio编辑器会在"选择"中抱怨错误
IQueryable<V> d = _src.Where(s => s.Right - 1 == s.Left).Select(s=> new V());
Run Code Online (Sandbox Code Playgroud)
错误是:
The type arguments cannot be inferred from the usage. Try specifying the type arguments explicitly.
Candidates are:
System.Collections.Generic.IEnumerable<V> Select<U,V>(this System.Collections.Generic.IEnumerable<U>, System.Func<U,V>) (in class Enumerable)
System.Linq.IQueryable<V> Select<U,V>(this System.Linq.IQueryable<U>, System.Linq.Expressions.Expression<System.Func<U,V>>) (in class Queryable)
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释这种现象,解决错误的方法是什么?
===编辑(2010-03-16 5:35 pm)===
谢谢Mike Two.我也尝试了一个像你这样的简单例子.它可以工作,但这不是我的.我发布的代码如下:
public class NSM<U, V> where U …Run Code Online (Sandbox Code Playgroud) 以下测试是在 CentOS 7.1 中进行的。
创建以下文件test.service中/usr/lib/systemd/system/
[Unit]
Description=Test Bash Brace Expansion
Wants=network.target
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c "a='hello world'; echo ${a}"
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
并执行 systemctl daemon-reload; systemctl restart test; systemctl status test -l
没有值的输出,因为${a}不作为词替代hello world,直到它echo ${a}变成
echo $a : 工作 echo $${a}: 工作这$$意味着 aa bash 中进程的 pid,但是为什么可以通过$$这个技巧ExecStart来获得这个词hello world呢?