Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
set and get in c# classes
12-05-2009, 04:54 PM
Post: #1
set and get in c# classes
What do yall think about the set and get builtins for C# classes. I don't like it as much because it feels like I have direct access to class variables. I just feel like it breaks convents that I have been built on in c, c++, pascal, and java. For example if I wanted to modified or access a variable I would make 2 function. Here is a example:
class GradeBook
{
public:
string getCourseName()
{
return coursename;
}
void setCourseName(string course)
{
coursename = course;
}
private:
string coursename;
};

This is a c++ example you can do it the same way in c# but by convention they want you to use the get, set and value to access and modify variables.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: