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 trial

C# C# Objects Encapsulation with Properties Properties

Ashek Ahmmed
PLUS
Ashek Ahmmed
Courses Plus Student 3,664 Points

How does the set property work? The variable "value" was not defined inside the property "Location".

the variable "value" is local to the set accessor method, so how does it become available to the set property? It would have been more comprehensible, had the instructor complied this program.

2 Answers

Steven Parker
Steven Parker
231,268 Points

"Set" uses an implicit parameter called "value" which is provided by the language and does not need to be explicitly defined. In fact, it is an error to use "value" for a local variable declaration in a set accessor.