|
|
|
Click here to copy the following block |
Function CloneObject(ByVal obj As Object) As Object Dim ms As New System.IO.MemoryStream(1000) Dim bf As New BinaryFormatter(Nothing, _ New StreamingContext(StreamingContextStates.Clone)) bf.Serialize(ms, obj) ms.Seek(0, SeekOrigin.Begin) CloneObject = bf.Deserialize(ms) ms.Close() End Function
Sub TestCloneObject() Dim p1 As New Person("Joe", "Doe", #1/2/1960#) Dim p2 As New Person("Ann", "Smith", #3/4/1965#) p1.Spouse = p2 p2.Spouse = p1
Dim q1 As Person = DirectCast(CloneObject(p1), Person) Dim q2 As Person = q1.Spouse Console.WriteLine(q1.FirstName & " " & q1.LastName) Console.WriteLine(q2.FirstName & " " & q2.LastName) Console.WriteLine("P1 is Q1 = {0}", p1 Is q1) Console.WriteLine("P2 is Q2 = {0}", p2 Is q2) End Sub
|
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|