|
-
Jan 12th, 2010, 06:28 PM
#13
Re: Default Property Values
To answer the original question, setting field values where they're declared can be optimised by the compiler, so it's preferred over setting in the constructor, which can't be optimised.
If you do choose to set in the constructor for some reason, and there could be valid reasons, then code duplication isn't an issue. You simply put the code in the default constructor and then invoke that from the others. If that's not possible for some reason, you simply create an Initialise method and set the field values there, calling that method from wherever it's appropriate.
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
|