C# Error CS0719 – ‘{0}’: array elements cannot be of static type

C# Error

CS0719 – ‘{0}’: array elements cannot be of static type

Reason for the Error & Solution

‘type’: array elements cannot be of static type

An array of static type does not make sense since array elements are instances, but it is not possible to create instances of static types.

The following sample generates CS0719:

// CS0719.cs  
public static class SC  
{  
   public static void F()  
   {  
   }  
}  
  
public class CMain  
{  
   public static void Main()  
   {  
      SC[] sca = new SC[10];  // CS0719  
   }  
}  

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...