怎么用byval而不是byref给类赋值??

dim cart as collection
Dim itemForC As CartItem
itemForC = Cart.Item(1)

对itemForC做一些操作,发现cart里面对应的也该变了,好像是byref传递给了itemForC.我现在想byval,怎么实现呀?
cartItem是我定义的一个类。
---------------------------------------------------------------

铁出来你的代码
---------------------------------------------------------------

呵呵,如果你的那个类是自己写的,那么可以将Class改成Structure。
Structure CartItem
...
End Structure

或者如果不方便改的的话,在赋给Collection/Array的时候Clone一下:
itemForC = Cart.Item(1).Clone

不过这个Clone方法可能要你自己写一下了,很多VS.NET自己提供的类都有这个方法的。

Published At
Categories with Web编程
Tagged with
comments powered by Disqus