Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
Pete O'Hanlon2-Jan-18 22:20
mvePete O'Hanlon2-Jan-18 22:20 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
User987432-Jan-18 23:06
professionalUser987432-Jan-18 23:06 
AnswerRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
OriginalGriff2-Jan-18 22:45
mveOriginalGriff2-Jan-18 22:45 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
User987432-Jan-18 23:06
professionalUser987432-Jan-18 23:06 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
Marc Clifton6-Jan-18 4:19
mvaMarc Clifton6-Jan-18 4:19 
AnswerRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
BillWoodruff4-Jan-18 23:07
professionalBillWoodruff4-Jan-18 23:07 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
User987435-Jan-18 13:18
professionalUser987435-Jan-18 13:18 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
BillWoodruff5-Jan-18 21:13
professionalBillWoodruff5-Jan-18 21:13 
@Rick_Bishop @Marc-Clifton

Hi Rick,

If you do get into the "functional programming" thing, as in F#, you will have reasons, imho, to think about the issue of "immutability" ... F# enforces that strictly.

Marc Clifton's recent articles here that demonstrate FP approaches with C# are very interesting.

I am inclined, now, to do without 'ref and 'out, and make my classes as immutable as possible using 'get only Properties, etc. You can see this in the second extension method above named 'Clone.

With a very complex Class, copying all the field/property values into a new object might be very expensive; in that case, is the Class "more immutable" if there is a specific method that modifies one or more class instance members values ? Not yet sure on that one.

In any case, I think it imperative to think carefully about when, how, and where, any Class instance may be modified.

cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12

GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
Marc Clifton6-Jan-18 4:14
mvaMarc Clifton6-Jan-18 4:14 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
BillWoodruff6-Jan-18 7:40
professionalBillWoodruff6-Jan-18 7:40 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
Marc Clifton8-Jan-18 3:03
mvaMarc Clifton8-Jan-18 3:03 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
BillWoodruff8-Jan-18 5:18
professionalBillWoodruff8-Jan-18 5:18 
GeneralRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
User9874315-Jan-18 4:10
professionalUser9874315-Jan-18 4:10 
AnswerRe: Is it wrong to pass an object into a method, change something and then pass it back to the caller? Pin
Marc Clifton6-Jan-18 3:56
mvaMarc Clifton6-Jan-18 3:56 
QuestionC# Progammer Forum for Beginners? Pin
User987432-Jan-18 21:27
professionalUser987432-Jan-18 21:27 
AnswerRe: C# Progammer Forum for Beginners? Pin
Ralf Meier2-Jan-18 21:55
mveRalf Meier2-Jan-18 21:55 
AnswerRe: C# Progammer Forum for Beginners? Pin
OriginalGriff2-Jan-18 22:09
mveOriginalGriff2-Jan-18 22:09 
GeneralRe: C# Progammer Forum for Beginners? Pin
Pete O'Hanlon2-Jan-18 22:15
mvePete O'Hanlon2-Jan-18 22:15 
GeneralRe: C# Progammer Forum for Beginners? Pin
OriginalGriff2-Jan-18 22:36
mveOriginalGriff2-Jan-18 22:36 
GeneralRe: C# Progammer Forum for Beginners? Pin
Pete O'Hanlon2-Jan-18 22:43
mvePete O'Hanlon2-Jan-18 22:43 
GeneralRe: C# Progammer Forum for Beginners? Pin
OriginalGriff2-Jan-18 22:49
mveOriginalGriff2-Jan-18 22:49 
GeneralRe: C# Progammer Forum for Beginners? Pin
Dave Kreskowiak3-Jan-18 2:23
mveDave Kreskowiak3-Jan-18 2:23 
GeneralRe: C# Progammer Forum for Beginners? Pin
OriginalGriff3-Jan-18 2:33
mveOriginalGriff3-Jan-18 2:33 
GeneralRe: C# Progammer Forum for Beginners? Pin
Dave Kreskowiak3-Jan-18 4:18
mveDave Kreskowiak3-Jan-18 4:18 
GeneralRe: C# Progammer Forum for Beginners? Pin
OriginalGriff3-Jan-18 4:46
mveOriginalGriff3-Jan-18 4:46 

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.