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

.NET (Core and Framework)

 
GeneralRe: Date formatting issue Pin
Luc Pattyn22-Dec-09 9:18
sitebuilderLuc Pattyn22-Dec-09 9:18 
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 
Hey,

I'm a little confused with the definition of a shallow copy. From the definitions I can find online, I get that reference types get copied, but not the value they refer to. In other words, they should point to the same value. However, when I test this, I can assign a new value to a reference type in either the original or the copy, and the value in it's counterpart won't change.

This is the code I used to test this:

Sub Main()
    Dim list1 As New List(Of Spam)
    list1.Add(New Spam(1))
    list1.Add(New Spam(2))
    list1.Add(New Spam(3))

    Dim list2 As List(Of Spam)
    list2 = list1.GetRange(0, list1.Count) ' this should make a shallow copy
    list2.Item(1) = New Spam(5)

    For Each s As Spam In list1
        Console.Write(s.ToString & " ")
    Next
    Console.ReadKey()
End Sub


Private Class Spam
    Public Sub New(ByVal v As Integer)
        value = v
    End Sub
    Dim value As Integer
    Public Overrides Function ToString() As String
        Return value.ToString
    End Function
End Class


The output of this code is "1 2 3", and not "1 5 3", which I'd expect from the definition of a shallow copy.

Please un-confuse me here Smile | :)

Cheers!

Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!

AnswerRe: Shallow and deep copies Pin
Luc Pattyn20-Dec-09 6:53
sitebuilderLuc Pattyn20-Dec-09 6:53 
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 

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.