Skip to content
Discussion options

You must be logged in to vote

Per the spec, value is not technically a keyword:

The implicit parameter of a set accessor is always named value.

This means your setter basically behaves as if it was a method with the signature public void SetValue(int value) and you can't use @value to refer to the field in such a method either. You can use this.value, though:

private int value;
public int Value { get => value; set => this.value = value; }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jnm2
Comment options

jnm2 Nov 1, 2021
Collaborator

Answer selected by RikkiGibson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants