Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: Console Application Pin
mil_an13-Mar-04 10:24
mil_an13-Mar-04 10:24 
GeneralRe: Console Application Pin
Nick Parker13-Mar-04 10:45
protectorNick Parker13-Mar-04 10:45 
GeneralRe: Console Application Pin
mil_an13-Mar-04 8:12
mil_an13-Mar-04 8:12 
GeneralRe: Console Application Pin
CWIZO13-Mar-04 8:28
CWIZO13-Mar-04 8:28 
GeneralRe: Console Application Pin
oOomen13-Mar-04 22:11
oOomen13-Mar-04 22:11 
QuestionHow can a class call one of its own accessors? Pin
Adrian Stanley13-Mar-04 3:57
Adrian Stanley13-Mar-04 3:57 
AnswerRe: How can a class call one of its own accessors? Pin
John Fisher13-Mar-04 4:20
John Fisher13-Mar-04 4:20 
AnswerRe: How can a class call one of its own accessors? Pin
Jeff Varszegi13-Mar-04 16:15
professionalJeff Varszegi13-Mar-04 16:15 
Yes. You could have easily determined this by a test-- calling the accessor from the constructor and checking the result, maybe with a WriteLine statement in the setter. I'm not griping, just trying to save you some trouble for next time!

Your question is a good one; writing your code this way is often a smart thing to do for maintainability-- this way any validation for each property can be located in one place. I believe it could in some cases slightly degrade performance over setting your properties in the constructor, since each property set amounts to a method call, but the .NET compiler should in any even inline those calls unless they're over a certain size limit.

Conceptually speaking, you probably could've guessed the answer without testing if you'd written it this way:

this.DummyProperty = dbl;

As for me, I never use 'this' except for in a few specific situations, like writing a copy method.

Regards,

Jeff Varszegi
AnswerRe: How can a class call one of its own accessors? Pin
Michael Flanakin17-Mar-04 19:19
Michael Flanakin17-Mar-04 19:19 
GeneralDataGrid Sorting Pin
jazzle13-Mar-04 3:37
jazzle13-Mar-04 3:37 
GeneralRe: DataGrid Sorting Pin
Mazdak13-Mar-04 9:40
Mazdak13-Mar-04 9:40 
GeneralRe: DataGrid Sorting Pin
jazzle13-Mar-04 10:42
jazzle13-Mar-04 10:42 
GeneralRe: DataGrid Sorting Pin
Mazdak13-Mar-04 18:30
Mazdak13-Mar-04 18:30 
GeneralRe: DataGrid Sorting Pin
jazzle14-Mar-04 1:41
jazzle14-Mar-04 1:41 
GeneralRe: DataGrid Sorting Pin
jazzle14-Mar-04 9:52
jazzle14-Mar-04 9:52 
GeneralRe: DataGrid Sorting Pin
Mazdak14-Mar-04 9:57
Mazdak14-Mar-04 9:57 
GeneralRe: DataGrid Sorting Pin
jazzle14-Mar-04 10:07
jazzle14-Mar-04 10:07 
Generalhelp me Pin
vatavua13-Mar-04 3:21
vatavua13-Mar-04 3:21 
GeneralRe: help me Pin
Dave Kreskowiak13-Mar-04 4:26
mveDave Kreskowiak13-Mar-04 4:26 
GeneralRe: help me Pin
Corinna John13-Mar-04 8:18
Corinna John13-Mar-04 8:18 
GeneralRender child controls into memory dc Pin
Mathew Hall13-Mar-04 2:18
Mathew Hall13-Mar-04 2:18 
GeneralBit to Byte and base type size in C# Pin
Tristan Rhodes13-Mar-04 1:25
Tristan Rhodes13-Mar-04 1:25 
GeneralRe: Bit to Byte and base type size in C# Pin
leppie13-Mar-04 3:06
leppie13-Mar-04 3:06 
GeneralRe: Bit to Byte and base type size in C# Pin
Tristan Rhodes13-Mar-04 4:08
Tristan Rhodes13-Mar-04 4:08 
GeneralRe: Bit to Byte and base type size in C# Pin
leppie13-Mar-04 6:50
leppie13-Mar-04 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.