我執行在vb.net定製的圖形算法,我有以下問題:.net集合:如何將對象從一個集合複製到另一個集合?
Supose代碼:
dim col as new collection
dim myC as new system.collections.genericList(of myClass)
dim obj1 as new myClass
dim obj2 as new myClass
myC.add(obj1)
myC.add(obj2)
dim myC2 as new system.collections.generic.list(of myClass)
myC2 = myC
col.add(myc2)
'In the next statement, the myC2 inside col collection will be decreased to contain
'only obj1, like myC. I supose this is for myC and myC2 contains only a pointer to
'objects obj1 and obj2 as well col contains pointers to myC and myC2
myC.remove(obj2)
'The problem is that I have to only copy myC to myC2, like a ByVal argument in a function,
'instead a ByRef argument, in order to mantain a copy of objects in myC2 while these
'objects should be removed from myC. How should I do it?
感謝您的幫助......
完全簡單和偉大!非常感謝! – Alex