C# Error CS0716 – Cannot convert to static type ‘{0}’

C# Error

CS0716 – Cannot convert to static type ‘{0}’

Reason for the Error & Solution

Cannot convert to static type ‘type’

This error occurs if your code uses a cast to convert to a static type. Since it is not possible for an object to be an instance of a static type, casting to a static type can never be a meaningful cast.

Example

The following sample generates CS0716:

// CS0716.cs  
  
public static class SC  
{  
    static void F() { }  
}  
  
public class Test  
{  
    public static void Main()  
    {  
        object o = new object();  
        System.Console.WriteLine((SC)o);  // CS0716  
    }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...