Show/Hide Toolbars

XSharp

The best overloaded method match for 'method' has wrong signature for the initializer element. The initializable Add must be an accessible instance method.

 

This error is generated when you try to use a collection initializer with a class that has no public non-static Add method. If the Add method is not accessible because of its protection level (private, protected, internal) then you will get XS0122, so that this error probably means that the method is defined as static.

 

Example

 

The following example generates XS1921:

 

 

// XS1921.prg