hey guys,
I`m a beginner in c# and I have a problem in using set/get in classes.
actually I didn`t get why do we use them,can anyone please introduce them briefly for me?
3pid
0
Newbie Poster
Recommended Answers
Jump to PostYou don't need to use set or get. You could write functions named setFoo or getFoo instead of using a property Foo:
class Point { double x, y; public Point(double x, double y) { this.x = x; this.y = y; } public double GetX() { return x; …
Jump to PostA reason to use get/set is so that your class contains control over the input
For example
Exam results shoul dbe between 0-100
No exact type exists to hold only 0-100, so, if the class has a set which validates the data, it cant ever have an …
All 7 Replies
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
LizR
171
Posting Virtuoso
Rashakil Fol
commented:
yes
+9
3pid
0
Newbie Poster
serban
0
Newbie Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
serban
0
Newbie Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.