The original answer is below and is wrong because the new way of writing gave room to misunderstand (no one else noticed - curious how right things get negative and wrong things don’t). The certain is:
This is a property. It’s quite obvious, it has no parentheses, and every method has its identifier followed by parentheses. How could this be a method?
This is a property that is being initialized with a value, in case a lambda and that you can only take this value since it was not created nor a getter neither a Setter. In this case the compiler creates the getter to access this value, otherwise it would be better to delete everything since it would be inaccessible.
See how it’s really like that in the Sharplab.
Doesn’t stop turning into a method get
, but in your code is a property.
I still think it could be done in a more simplified way, but it must be some requirement framework.
This is a method. The use of notation =>
in this case is not appropriate since there is more than one line effectively, although it is a single statement.
I doubt whether the code is necessary or should be so, but it is not possible to say without context.
More readable:
public ICommand ChangePositionCommand {
return new Command((obj) => {
_positionIndex++;
if (_positionIndex >= Positions.Count)
_positionIndex = 0;
Position = Positions[_positionIndex];
RaisePropertyChanged(nameof(Position));
});
}
I put in the Github for future reference.
Attribute I guarantee it’s not.
See the Reply Issue.
– Maniero