Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed C# Objects!
You have completed C# Objects!
Preview
Simple properties can be written even more succinctly as automatically implemented properties.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Properties can also be used to
perform better encapsulation.
0:00
Look at the _location
property we just wrote.
0:00
We can remove either the getter or
the setter portion of the property.
0:02
Think about what would happen
if we removed the getter.
0:06
This means other classes can set the value
of the location, but they can't read it.
0:10
Methods and
other properties within the Invader class
0:16
could still read the location by
using the private field directly.
0:18
What if we remove the setter instead?
0:24
Now other classes can get the _location,
but they can't set it.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up