Mam następujący kod, który mam opracowującym w .NET 4.0 projektutypu lub nazwa przestrzeni nazw „T” nie można znaleźć
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;
}
}
}
}
}
ale coraz następujące błędy. Mam System.dll już włączone jako domyślny w referencjach. Co mogę robić źle?
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, założyłem, że nie można utworzyć statycznej klasy ogólnej. –
@PaulPhillips - I rzeczywiście tak spróbowałem i nie sądzę że można. Usunąłem tę część odpowiedzi. – SwDevMan81
Dostałem go do pracy w LINQPad, chociaż powołanie jest trochę niezdarny. Trzeba zrobić 'Utility .Filter()' –