xsharp.eu • X# Feature: Scoped classes
Page 1 of 1

X# Feature: Scoped classes

Posted: Thu Aug 22, 2019 4:25 pm
by wriedmann
Hello,

it is now the second consecutive day I'm using a language feature that is new to X# (and that maybe most people coming from VO does not knows):

Code: Select all

class MyClass
....
  class MyDetailClass
  ...
  end class

end class
The beauty is that the class MyDetailClass is visibile only in the MyClass itself, and not externally to it.

I'm using that instead of using multidimensional arrays, and I think this makes code much clearer.

Wolfgang

X# Feature: Scoped classes

Posted: Thu Aug 22, 2019 7:09 pm
by robert
Wolfgang,

Yes this works. And you can use both List<MyDetailClass> as well as ARRAY OF MyDetailClass syntax

Robert

X# Feature: Scoped classes

Posted: Fri Aug 23, 2019 5:10 am
by wriedmann
Hi Robert,

I prefer the array of MyDetailClass because I can use ASort() and AScan() then - I need both.
I know that you don't agree, but ASort() and AScan() as so powerful that I have found no corresponding possibility with the List collection class.

Wolfgang

X# Feature: Scoped classes

Posted: Fri Aug 23, 2019 5:22 am
by wriedmann
Hi Robert,

in my testclass this works:

Code: Select all

class MyExternalClass
	protect _aData			as array of MyInternalClass

  class MyInternalClass

  	constructor()

  end class

end class
but unfortunately it gives an error in my real code:

Code: Select all

error XS0310: 'clsTechnikerStatistik.TechnikerStatistikDetail' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'XSharp.__ArrayBase<T>'
The class TechnikerStatistikDetail has a public parameterless constructor.....

Code: Select all

class TechnikerStatistikDetail
public constructor()
    self:Aufnr := 0
    return

public property Aufnr as int auto
end class
I'm will try to reproduce this in my sample class.

Wolfgang