|
-
Aug 7th, 2009, 03:36 PM
#1
Thread Starter
Addicted Member
How do I set a property?
How do I set a property from within the class it is defined in?
-
Aug 7th, 2009, 03:44 PM
#2
Re: How do I set a property?
Typically in the contructor you set the class's properties just like you were setting any other variable.
-
Aug 7th, 2009, 03:48 PM
#3
Re: How do I set a property?
generally a property is the public exposure of some private field. This isn't always the case, but it is the most common.
So when you want to do what you are asking, you need to decide if you just want to set the backing field, or if you want to set the property which then sets the backing field. The difference being if the property set does any additional things, like fire a property changed event or something along those lines. Sometimes it is desirable to have this and sometimes it is not, it is all up to your code and what it is supposed to be doing.
So from within the class, you have the ability to bypass the property and just set the backing field to whatever value it needs to be set to.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|