Show/Hide Toolbars

XSharp

'variable' is of type 'type'. A const field of a reference type other than string can only be initialized with null.

 

A constant-expression is an expression that can be fully evaluated at compile-time. Because the only way to create a non-null value of a reference-type is to apply the new operator, and because the new operator is not permitted in a constant-expression, the only possible value for constants of reference-types other than string is null.

 

If you encounter this error by trying to create a const string array, the solution is to make the array readonly, and initialize it in the constructor.

Example

 

The following example generates XS0134.

 

 

// XS0134.prg  
// compile with: /target:library