using System.Collections.Generic
class xCompare
public property MyValue as string auto
end class
class xComparer<xCompare> implements IComparer<xCompare>
method Compare( o1 as xCompare, o2 as xCompare ) as int
local nReturn as int
local c1 as string
local c2 as string
c1 := o1:MyValue // error XS1061: 'xCompare' does not contain a definition for 'MyValue' and no accessible extension method 'MyValue' accepting a first argument of type 'xCompare' could be found
c2 := o2:MyValue // error XS1061: 'xCompare' does not contain a definition for 'MyValue' and no accessible extension method 'MyValue' accepting a first argument of type 'xCompare' could be found
nReturn := String.Compare( c1, c2 )
return nReturn
end class
The error seems to have to do with the fact that the Compare method is using generics.
When I remove the generics part from the method declaration, the code compiles without error.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
This is because there's a name conflict between the name of the Generic class param and the type having the same named. Normally the naming convention you would use for that is
class xComparer<T> implements IComparer<xCompare>
if what you intended to do was to force the generic param being of type xCompare, then you would need to use
class xComparer<T> implements IComparer<xCompare> where T is xCompare