Error del compilador CS0308
Actualización: noviembre 2007
Mensaje de error
El 'identificador' de tipo o método no genérico no se puede utilizar con argumentos de tipo.
The non-generic type-or-method 'identifier' cannot be used with type arguments.
El método o el tipo no es genérico, pero se utilizó con argumentos de tipo. Para evitar este error, quite los corchetes angulosos y escriba argumentos, o vuelva a declarar el método o el tipo como un tipo o método genérico.
El ejemplo siguiente genera el error CS3008:
// CS0308a.cs
class MyClass
{
public void F() {}
public static void Main()
{
F<int>(); // CS0308 – F is not generic.
// Try this instead:
// F();
}
}
El ejemplo siguiente también genera el error CS3008: Para resolver el error, utilice la directiva "using System.Collections.Generic".
// CS0308b.cs
// compile with: /t:library
using System.Collections;
// To resolve, uncomment the following line:
// using System.Collections.Generic;
public class MyStack<T>
{
// Store the elements of the stack:
private T[] items = new T[100];
private int stack_counter = 0;
// Define the iterator block:
public IEnumerator<T> GetEnumerator() // CS0308
{
for (int i = stack_counter - 1 ; i >= 0; i--)
yield return items[i];
}
}