Click here to Skip to main content
16,006,768 members
Home / Discussions / C#
   

C#

 
AnswerRe: Drawing Digital Signal Pin
Bert delaVega17-Jul-07 6:24
Bert delaVega17-Jul-07 6:24 
QuestionCopying objects by value Pin
jozsurf16-Jul-07 17:59
jozsurf16-Jul-07 17:59 
AnswerRe: Copying objects by value Pin
originSH16-Jul-07 22:09
originSH16-Jul-07 22:09 
AnswerRe: Copying objects by value Pin
Luc Pattyn16-Jul-07 22:47
sitebuilderLuc Pattyn16-Jul-07 22:47 
GeneralRe: Copying objects by value Pin
jozsurf16-Jul-07 23:42
jozsurf16-Jul-07 23:42 
GeneralRe: Copying objects by value Pin
Luc Pattyn17-Jul-07 0:20
sitebuilderLuc Pattyn17-Jul-07 0:20 
GeneralRe: Copying objects by value Pin
jozsurf17-Jul-07 15:06
jozsurf17-Jul-07 15:06 
GeneralRe: Copying objects by value Pin
Luc Pattyn17-Jul-07 16:45
sitebuilderLuc Pattyn17-Jul-07 16:45 
Hi,


m_settings = SavedData.DefaultSettings;
is quite misleading, it seems to copy a lot of settings, but since it really is a ref type
its just copying the reference as you pointed out. This does not feel good.
Of course, if you have two labels (label1 and label2) on a form, then label1=label2;
also does not change any of the labels, it simply throws away the ref to one of them.

m_settings = new SettingsClass(SavedData.DefaultSettings); is a big no no for me, it does
not reveal the intention.

m_settings = SavedData.DefaultSettings.Clone(); is what I would do, it is much more intuitive.
It resembles list2=list1.Clone(); when you need a copy of an ArrayList so you can modify
list2 while keeping list1 intact.

As I have pointed out in a previous reply, the Clone() method is a combination of
a "new" statement and a copy operation (together, you might call that a copy constructor,
but AFAIK that is not a regular notion in C#)


I am not quite sure I understood it all, the following points are still unclear to me;
I did not need the answers to answer your question, but a better understanding might
(or might not) allow me to propose another approach altogether.

1. the settings (either actual, or default) are stored in a class (SettingsClass) ?
2. you need at least two instances of it, one for defaults, one for actuals ?
3. a ref to both instances, and a lot of other stuff, are stored in SavedData ?
4. you want to be able to modify the default settings ?
5. where did you obtain the default settings ? I guess from a file ? XML ?
6. are you going to save everything (all of SavedData) at once and in one location ?
7. if default settings can be changed, what is the meaning of settings ?
8. is SettingsClass just a list of value types, or does it also contain references
(e.g. strings) ?
9. do you need more than one clone ? I would expect it contains all settings, so you
start of with the defaults, copy once, then modify at will, but your message seems
to suggest you often need a copy ??

Cheers

Smile | :)



GeneralRe: Copying objects by value Pin
jozsurf17-Jul-07 16:59
jozsurf17-Jul-07 16:59 
GeneralRe: Copying objects by value [modified] Pin
Luc Pattyn17-Jul-07 17:15
sitebuilderLuc Pattyn17-Jul-07 17:15 
GeneralRe: Copying objects by value Pin
jozsurf17-Jul-07 18:07
jozsurf17-Jul-07 18:07 
GeneralRe: Copying objects by value Pin
Luc Pattyn22-Jul-07 12:00
sitebuilderLuc Pattyn22-Jul-07 12:00 
QuestionHow to set and get Windows Application's Version? Pin
Khoramdin16-Jul-07 17:21
Khoramdin16-Jul-07 17:21 
AnswerRe: How to set and get Windows Application's Version? Pin
Vikram A Punathambekar16-Jul-07 17:40
Vikram A Punathambekar16-Jul-07 17:40 
QuestionRe: How to set and get Windows Application's Version? Pin
Khoramdin16-Jul-07 19:20
Khoramdin16-Jul-07 19:20 
AnswerRe: How to set and get Windows Application's Version? Pin
Vikram A Punathambekar16-Jul-07 21:05
Vikram A Punathambekar16-Jul-07 21:05 
AnswerRe: How to set and get Windows Application's Version? Pin
originSH16-Jul-07 22:14
originSH16-Jul-07 22:14 
AnswerRe: How to set and get Windows Application's Version? Pin
ekynox17-Jul-07 13:33
ekynox17-Jul-07 13:33 
QuestionDataGrid date AND time Column[modified] Pin
swjam16-Jul-07 14:24
swjam16-Jul-07 14:24 
AnswerRe: DataGrid date AND time Column[modified] Pin
Michael Sync16-Jul-07 17:39
Michael Sync16-Jul-07 17:39 
GeneralRe: DataGrid date AND time Column[modified] Pin
swjam16-Jul-07 20:59
swjam16-Jul-07 20:59 
GeneralRe: DataGrid date AND time Column[modified] Pin
Rhys Gravell16-Jul-07 23:09
professionalRhys Gravell16-Jul-07 23:09 
Questionadd a page Pin
daku116-Jul-07 12:47
daku116-Jul-07 12:47 
AnswerRe: add a page Pin
T.EDY16-Jul-07 17:06
T.EDY16-Jul-07 17:06 
AnswerRe: add a page Pin
Sathesh Sakthivel16-Jul-07 17:20
Sathesh Sakthivel16-Jul-07 17:20 

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.