ccc Posted June 3, 2003 Posted June 3, 2003 Okay, I know what byVal and byRef do, ByVal passes a copy of an object, and ByRef passes the actual object, but lets say I have this code: Class myTest Event myEvent(ByVal sender as myTest) sub FireEvent() RaiseEvent myEvent(me) end sub End Class sub RunTest() dim mTest as new myTest addhandler mTest.myEvent, addressof del_myEvent mTest.FireEvent end sub sub del_myEvent(byval sender as myTest) RemoveHandler sender.myEvent,addressof del_myevent end sub Will the object mTest's handler be unassigned correctly? Or since i've passed a copy of the object, the original will still fire again? Should I just stick to writing everything byref instead? My application seems to eat up alot of memory, because something is getting stuck and not used. It uses a similar structure to the code above. Any tips? Any help would be appreciated. Thanks. :confused: Quote
*Gurus* divil Posted June 3, 2003 *Gurus* Posted June 3, 2003 Your class is a reference type, so it'll always be passed by reference. Only value types (structures and the primitives) can actually be passed by value. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
ccc Posted June 3, 2003 Author Posted June 3, 2003 Thank you, that really cleared everything up for me. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.