Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialThanitsak Leuangsupornpong
7,490 PointsConfuse about naming parameter in Setter that use word value.
I just want to know that why we need to use word value instead of normal word, because the word value is a keyword not the normal text that we use to name things. Is there something special in order to name parameter in Setter method? Thank you in advance
2 Answers
Steven Parker
231,198 PointsThe word "value" is not a reserved word in C#.
You may be thinking of how it is a contextual keyword in the set accessor of property declarations..
But here, it is just an ordinary name for a variable, but a good choice for the name of the parameter passed to a setter method.
Evan Welch
1,815 PointsI'm reading here because I am having trouble figuring how one value could be enough information for a location which needs a x, y, and map argument. After all MapLocation(int x, int y, Map map) needs three arguments x, y, and map.
Thank you for any help!
Steven Parker
231,198 PointsYou may be confusing constructor parameters (like "int x, int y, Map map") with a set accessor value.
You can have any number of constructor parameters.
Thanitsak Leuangsupornpong
7,490 PointsThanitsak Leuangsupornpong
7,490 PointsThank You very much for the answer! But in the property or auto-property we need to use value keyword for setter right? So that it can store value like variable as teacher said.
Steven Parker
231,198 PointsSteven Parker
231,198 PointsRight. As I said, when working with properties, the name "value" is what is known as a contextual keyword.
Thanitsak Leuangsupornpong
7,490 PointsThanitsak Leuangsupornpong
7,490 PointsI see, much appreciate!