Click here to Skip to main content
15,903,385 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionAppDomains and native window message handlers Pin
rogerkhoueiry22-Dec-09 4:02
rogerkhoueiry22-Dec-09 4:02 
QuestionTAG control [modified] Pin
ghbloos20-Dec-09 23:09
ghbloos20-Dec-09 23:09 
AnswerRe: TAG control Pin
hattonjohn17-Feb-10 12:01
hattonjohn17-Feb-10 12:01 
GeneralRe: TAG control Pin
ghbloos21-Feb-10 22:11
ghbloos21-Feb-10 22:11 
Questionin javascript, how to get a struct return by C# Pin
coderormnger20-Dec-09 18:58
coderormnger20-Dec-09 18:58 
AnswerRe: in javascript, how to get a struct return by C# Pin
coderormnger23-Dec-09 19:50
coderormnger23-Dec-09 19:50 
QuestionShallow and deep copies Pin
Jeroen De Dauw20-Dec-09 6:28
Jeroen De Dauw20-Dec-09 6:28 
AnswerRe: Shallow and deep copies Pin
Luc Pattyn20-Dec-09 6:53
sitebuilderLuc Pattyn20-Dec-09 6:53 
Dag Jeroen,

While you write

jeroen de dauw wrote:
I can assign a new value to a reference type


that does not really make sense (a type is a type, a type does not have a value at all); and it is not what list2.Item(1) = New Spam(5) does. Yes list2 is a reference type (it is an object, not a value type), as lists and arrays are collections holding things of a single type (either value types of reference types themselves). In this case, the list holds reference types, i.e. references to Spam instances.

What your statement does is it overwrites an existing reference by a reference to a new object. So none of the existing Spam objects is being modified.

As your use of the terminology isn't correct, this suggests you got a few things confused.

A shallow copy copies everything: the data in value types and the data in a reference type. The trick is a reference type only holds a reference (think of it as a pointer), and that is what gets copied. The thing (object) it points to is not being copied or cloned, so the old and new pointers now point to one and the same thing.

To prove, or rather disprove, your statement about shallow copies, you should add a Value property to the Spam class, then execute list2.Item(1).Value = 17 and watch how both lists reflect the change, as you now would have changed an existing object, where both lists are referring to.

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


GeneralRe: Shallow and deep copies Pin
Jeroen De Dauw20-Dec-09 6:59
Jeroen De Dauw20-Dec-09 6:59 
QuestionVB.Net - The dependency service does not exist or has been marked for deletion. (Exception from HRESULT: 0x80070433) Pin
Tony Teveris19-Dec-09 9:03
Tony Teveris19-Dec-09 9:03 
QuestionMemory Mapped File Pin
Wannes Geysen18-Dec-09 1:10
Wannes Geysen18-Dec-09 1:10 
AnswerRe: Memory Mapped File Pin
Dave Kreskowiak18-Dec-09 7:51
mveDave Kreskowiak18-Dec-09 7:51 
QuestionHow to Find the documentation oF MSPastry Library under MSDN ? Pin
ksaw12318-Dec-09 0:36
ksaw12318-Dec-09 0:36 
AnswerCPIGNORE: Duplicate post Pin
Dave Kreskowiak18-Dec-09 7:41
mveDave Kreskowiak18-Dec-09 7:41 
QuestionHow can I deploy an application using VISIFIRE Pin
cutudi16-Dec-09 4:13
cutudi16-Dec-09 4:13 
AnswerDuplicate post. Pin
Pete O'Hanlon16-Dec-09 4:55
mvePete O'Hanlon16-Dec-09 4:55 
AnswerRe: How can I deploy an application using VISIFIRE Pin
Dave Kreskowiak16-Dec-09 5:28
mveDave Kreskowiak16-Dec-09 5:28 
AnswerRe: How can I deploy an application using VISIFIRE Pin
The Man from U.N.C.L.E.22-Dec-09 7:16
The Man from U.N.C.L.E.22-Dec-09 7:16 
QuestionHow to change debugger enviorment Pin
Pankaj Saha16-Dec-09 1:18
Pankaj Saha16-Dec-09 1:18 
QuestionMerging Header Cells Pin
Kavyashri16-Dec-09 0:57
Kavyashri16-Dec-09 0:57 
AnswerRe: Merging Header Cells Pin
raghu.g16-Dec-09 20:20
raghu.g16-Dec-09 20:20 
QuestionEmail sent to client notification and tracking the link Pin
Niraj00115-Dec-09 22:02
Niraj00115-Dec-09 22:02 
QuestionHow do I Fill an Arbitrary Hex with a Centered Image Pin
jjwilson6115-Dec-09 9:53
jjwilson6115-Dec-09 9:53 
AnswerRe: How do I Fill an Arbitrary Hex with a Centered Image Pin
jjwilson6115-Dec-09 10:34
jjwilson6115-Dec-09 10:34 
QuestionMapping printers from a webpage Pin
Not Active15-Dec-09 7:52
mentorNot Active15-Dec-09 7:52 

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.