我有以下我在.NET 4.0项目类型或命名空间名称“T”找不到
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
public static class Utility
{
public static IEnumerable<T> Filter1(this IEnumerable<T> input, Func<T, bool> predicate)
{
foreach (var item in input)
{
if (predicate(item))
{
yield return item;
}
}
}
}
}
正在编译代码,但得到以下错误。 System.dll已经包含在引用中作为默认值。我可能做错了什么?
Error 1 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
+1,我假定你不能做一个静态类通用。 –
@PaulPhillips - 我其实只是试过了,我不认为你可以。我删除了这部分答案。 – SwDevMan81
我在linqpad上工作,虽然调用很笨拙。你必须做'Utility .Filter()' –