HomeCSharpC# Error CS0718 – ‘{0}’: static types cannot be used as type arguments

C# Error CS0718 – ‘{0}’: static types cannot be used as type arguments

C# Error

CS0718 – ‘{0}’: static types cannot be used as type arguments

Reason for the Error & Solution

‘type’: static types cannot be used as type arguments

Because a static type cannot be instantiated, it cannot be used as a generic argument. To resolve this error, remove the static type from the generic argument.

Example

The following sample generates CS0718:

// CS0718.cs  
public static class SC  
{  
    public static void F()  
    {  
    }  
}  
  
public class G<T>  
{  
}  
  
public class CMain  
{  
    public static void Main()  
    {  
        G<SC> gsc = new G<SC>();  // CS0718  
    }  
}  

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...