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 trialnfs
35,526 PointsAre Properties exclusive to C# only? or do other languages have this too?
public Maplocation Location
{
get
{
return something;
}
set
{
_value = value
}
}
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! Any object-oriented programming languages has properties. I know you know a bit of JavaScript so let's use an example from there for the time being.
Remember something like this from JS?
myArray = [2, 7, 4, 9];
myNumber = myArray.length;
An array is an Object in JavaScript and it has a length property. You can also create your own custom objects there (which I'm hoping you remember);
var student = {
name: "Nafis",
courses: ["JavaScript", "C#"]
}
studentName = student.name;
studentCourses = student.courses;
In this example, student
is an object with 2 properties: name
and courses
.
Hope this helps!
nfs
35,526 PointsThank you, Jennifer Nordell, for the quick answer.
I understand that every oo language has properties. Only the syntax is different, which makes it different from the other languages.
Jennifer Nordell
Treehouse TeacherYeah, sort of, but at the same time not really? Java and Swift can also have "getters" and "setters". There are probably others too
nfs
35,526 PointsThanks for that JavaScript analogy though, it really helped.