You have a class with a property.
You need to ensure that consumers of the class can write to the value of the property.
Which keyword should you use?
A.
value
B.
add
C.
get
D.
set
You have a class with a property.
You need to ensure that consumers of the class can write to the value of the property.
Which keyword should you use?
You have a class with a property.
You need to ensure that consumers of the class can write to the value of the property.
Which keyword should you use?
A.
value
B.
add
C.
get
D.
set
I would have answered “D”, keyword “set”. But of course you could use the keyword “value” in a set-accessor, so it’s not completely wrong.
Should be D. 🙂
D
I think there is nothing wrong with the answer this site offers. SET and VALUE are two things. Here the answer VALUE is much more appropriate.
The SET keyword defines an accessor method in a property or indexer that assigns the value of the property or the indexer element. However, the contextual keyword VALUE is used in the set accessor in ordinary property declarations. It is similar to an input parameter on a method. The word VALUE references the value that client code is attempting to assign to the property.
D: Set