Click here to Skip to main content
16,004,887 members
Home / Discussions / C#
   

C#

 
GeneralRe: OT Pin
Dan Neely20-Nov-06 9:49
Dan Neely20-Nov-06 9:49 
GeneralRe: OT [modified] Pin
Eric Dahlvang21-Nov-06 11:59
Eric Dahlvang21-Nov-06 11:59 
GeneralRe: OT Pin
Judah Gabriel Himango21-Nov-06 12:44
sponsorJudah Gabriel Himango21-Nov-06 12:44 
GeneralRe: OT Pin
Eric Dahlvang22-Nov-06 4:42
Eric Dahlvang22-Nov-06 4:42 
GeneralRe: OT Pin
Judah Gabriel Himango22-Nov-06 5:23
sponsorJudah Gabriel Himango22-Nov-06 5:23 
AnswerRe: Why can't properties be passed as out/ref parameters? Pin
Guffa20-Nov-06 6:49
Guffa20-Nov-06 6:49 
GeneralRe: Why can't properties be passed as out/ref parameters? Pin
Dan Neely20-Nov-06 8:20
Dan Neely20-Nov-06 8:20 
GeneralRe: Why can't properties be passed as out/ref parameters? Pin
Guffa20-Nov-06 20:55
Guffa20-Nov-06 20:55 
dan neely wrote:
the current situation can result in really ugly code though.

dataobject.someProperty = formObject.recomputeValue(dataobject.someProperty, otherValue1, otherValue2, ...);


Why do you think that the code is ugly? If the method returns a value, the return value is a good place to put it.

dan neely wrote:
or

int temp = dataobject.someProperty;
formObject.recomputeValue(out temp, otherValue1, otherValue2, ...);
dataobject.someProperty = temp;


That should actually be:

int temp;<br />
formObject.recomputeValue(out temp, otherValue1, otherValue2, ...);<br />
dataobject.someProperty = temp;


There is no reason to assign anything to a variable that is going to be used as an out parameter.

Using out/ref parameter and properties are two completely different approaches, so it's not at all a bad thing that they are separate in the code.

dan neely wrote:
vs

formObject.recomputeValue(out dataobject.someProperty, otherValue1, otherValue2, ...);


If that would be allowed, it would be implemented exactly as the code with the temporary variable, with the only exception that the the temporary variable doesn't have a name.

Allowing properties as out parameters would only serve to hide what's actually going on. In a language like VB that might be desired, but hardly in C#.

Shorter code is not always better code.


---
b { font-weight: normal; }

GeneralRe: Why can't properties be passed as out/ref parameters? Pin
Dan Neely21-Nov-06 2:56
Dan Neely21-Nov-06 2:56 
QuestionThe transaction has already been implicitly or explicitly committed or aborted. Pin
bemahesh20-Nov-06 5:05
bemahesh20-Nov-06 5:05 
AnswerRe: The transaction has already been implicitly or explicitly committed or aborted. Pin
Colin Angus Mackay20-Nov-06 5:41
Colin Angus Mackay20-Nov-06 5:41 
GeneralRe: The transaction has already been implicitly or explicitly committed or aborted. Pin
bemahesh20-Nov-06 5:58
bemahesh20-Nov-06 5:58 
GeneralRe: The transaction has already been implicitly or explicitly committed or aborted. Pin
Colin Angus Mackay20-Nov-06 6:25
Colin Angus Mackay20-Nov-06 6:25 
GeneralRe: The transaction has already been implicitly or explicitly committed or aborted. Pin
bemahesh20-Nov-06 8:39
bemahesh20-Nov-06 8:39 
GeneralRe: The transaction has already been implicitly or explicitly committed or aborted. Pin
Faiz VP12-Oct-09 3:22
Faiz VP12-Oct-09 3:22 
Questionxslt transformation Pin
Kamil.Nowicki20-Nov-06 5:03
Kamil.Nowicki20-Nov-06 5:03 
Questionassembly/project layout & app settings Pin
Jon Hulatt20-Nov-06 5:00
Jon Hulatt20-Nov-06 5:00 
Questionaction without getiing the focus Pin
Dobromir Dimitrov20-Nov-06 3:24
Dobromir Dimitrov20-Nov-06 3:24 
AnswerRe: action without getiing the focus Pin
Nader Elshehabi20-Nov-06 4:39
Nader Elshehabi20-Nov-06 4:39 
QuestionDataGridViewComboBox selected index Pin
Razvan Dimescu20-Nov-06 3:23
Razvan Dimescu20-Nov-06 3:23 
AnswerRe: DataGridViewComboBox selected index Pin
ednrgc20-Nov-06 3:31
ednrgc20-Nov-06 3:31 
GeneralRe: DataGridViewComboBox selected index Pin
Razvan Dimescu20-Nov-06 3:34
Razvan Dimescu20-Nov-06 3:34 
GeneralRe: DataGridViewComboBox selected index Pin
ednrgc20-Nov-06 3:38
ednrgc20-Nov-06 3:38 
GeneralRe: DataGridViewComboBox selected index Pin
Razvan Dimescu20-Nov-06 3:45
Razvan Dimescu20-Nov-06 3:45 
GeneralRe: DataGridViewComboBox selected index Pin
PunkIsNotDead15-Jun-09 10:16
PunkIsNotDead15-Jun-09 10:16 

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.