User Tools

Site Tools


property

Property

The property statement can have different forms in X# (it is the .NET equivalent for access/assign in VO). The “full” version (read and write):

property MyProp as string
  get
    return _cMyProp
  end get
  set
    _cMyProp := value
  end set
end property

The same in a one-line syntax:

property MyProp as string get _cMyProp set _cMyProp := value

Please note that there is no “return” in the get accessor, and no end statements. An “auto” property (that is a property that defines also the storage):

property MyProp as string auto

Of course you can also define one accessor as static:

property MyProp as string get _cMyProp static set _cMyProp := value

or define only the get (read) or set (write) accessor:

property MyProp as string get _cMyProp

You can even put more statements in a oneline property, using a comma as separator:

property MyProp as string get _cMyProp set _cMyProp := value, self:OnPropertyChanged("MyProp")

And nobody inhibits you to use more sofisticated code in a property:

public virtual property CloseButton as RelayCommand get self:_Get<RelayCommand>() set self:_Set( value )
property.txt · Last modified: 2020/08/28 04:04 by wolfgangriedmann