Show/Hide Toolbars

XSharp

No best type found for implicitly typed array.

 

Array elements must all be the same type or implicitly convertible to the same type according to the type inference rules used by the compiler. The best type must be one of the types present in the array expression. Elements will not be converted to a new type such as object. For an implicitly typed array, the compiler must infer the array type based on the type of elements assigned to it.

 

To correct this error

 

1.Give the array an explicit type.

2.Give all array elements the same type.

3.Provide explicit casts on those elements that might be causing the problem.

Example

 

The following code generates XS0826 because the array elements are not all the same type, and the compiler's type inference logic does not find a single best type:

 

 

// XS0826.prg