cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
Hi Guys..
Im having difficulty resolving a compiler warning (Option Strict is on) that says:
I have this:
elsewhere i say:
MyToolStripAddNewButton is a toolstrip button, and descended from object. the MyArrayList also contains normal Controls, and is iterated to enable or disable selected form elements at runtime. I have resolved the latebinding problems by inspecting the typeof at each iteration (may cause a performance hit - if it gets bad i might split the arraylist out into 2, one for controls and one for toolstripitems but for now, this is in place and it works..
So, my question is:
MyTolStripAddNewButton is being boxed into an object and passed by reference. I presume the error message comes when it is being unboxed again, but the issue i have is in the way vb seems to be handling the ByRef - it's literally making a new object, passing it in and then copying it back when it is done? This sounds a little dumb.. actually sounds a lot dumb, because there is then an implicit conversion that i cannot intervene on. My sub handles two objects with no common link in the hierarchy, so object is the only choice - how can i avoid suffering this compiler warning when my object is being copied instead of unboxed as the sub exits?
Im having difficulty resolving a compiler warning (Option Strict is on) that says:
Warning 1 Implicit conversion from 'Object' to 'System.Windows.Forms.ToolStripButton' in copying the value of 'ByRef' parameter 'o' back to the matching argument.
I have this:
VB.NET:
Public Sub MySub(byref o as object)
MyArrayList.Add(o)
End Sub
elsewhere i say:
VB.NET:
MySub(MyToolstripAddNewButton)
MyToolStripAddNewButton is a toolstrip button, and descended from object. the MyArrayList also contains normal Controls, and is iterated to enable or disable selected form elements at runtime. I have resolved the latebinding problems by inspecting the typeof at each iteration (may cause a performance hit - if it gets bad i might split the arraylist out into 2, one for controls and one for toolstripitems but for now, this is in place and it works..
So, my question is:
MyTolStripAddNewButton is being boxed into an object and passed by reference. I presume the error message comes when it is being unboxed again, but the issue i have is in the way vb seems to be handling the ByRef - it's literally making a new object, passing it in and then copying it back when it is done? This sounds a little dumb.. actually sounds a lot dumb, because there is then an implicit conversion that i cannot intervene on. My sub handles two objects with no common link in the hierarchy, so object is the only choice - how can i avoid suffering this compiler warning when my object is being copied instead of unboxed as the sub exits?