|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Array Objects pointers, value types reference types??I thought I understood .Net Framework with value types and referencetypes but apparently not. So I have this code. Excuse me if it's not 100% correct I cut and paste and shortened it a bit to make things clearer So basically the purpose of this code was to have to arrays passed in byref _BInfo and CInfo. Then base on another list of items that gets passed through is to fill one or the other. I was wanting to use a array of objects pointer to "point" to BInfo or CInfo Array 'Dim BInfo(,) As Object 'passed in byref 'Dim CInfo(,) As Object 'passed in byref ' Dim Mycoll as collection Dim NodetoSet(,) As Object Dim UpperBound As Integer For Each X in Coll Loop ' Not important If X.UseB Then ReDim BINFO(30, UBound(BInfo) + 1) NodetoSet = BINFO ' What is this doing. Is it copying data from BINFO to NodetoSet why? Shouldn't it treat as a pointer?? Else ReDim CInfo(30, UBound(CInfo) + 1) NodetoSet = CInfo ' What is this doing. Is it copying data from BINFO to NodetoSet why? Shouldn't it treat as a pointer?? End If UpperBound = UBound(NodetoSet, 2) - 1 'doing stuff with NodeToSet NodeToSet(UpperBound,1) = "hello" NodeToSet(UpperBound,1) = "goodbye" 'And so on.... Next Thanks in advance plau***@hotmail.com wrote:
Show quoteHide quote > Hi all, Ok, I can't say I fully understand what you are doing here, but I think > I thought I understood .Net Framework with value types and > referencetypes but apparently not. > So I have this code. Excuse me if it's not 100% correct I cut and paste > and shortened it a bit to make things clearer > So basically the purpose of this code was to have to arrays passed in > byref _BInfo > and CInfo. > Then base on another list of items that gets passed through is to fill > one or the other. > I was wanting to use a array of objects pointer to "point" to BInfo or > CInfo Array > > 'Dim BInfo(,) As Object 'passed in byref > 'Dim CInfo(,) As Object 'passed in byref > ' Dim Mycoll as collection > Dim NodetoSet(,) As Object > Dim UpperBound As Integer > > For Each X in Coll Loop ' Not important > If X.UseB Then > ReDim BINFO(30, UBound(BInfo) + 1) > NodetoSet = BINFO ' What is this doing. Is it > copying data from BINFO to NodetoSet why? Shouldn't it treat as a > pointer?? > Else > ReDim CInfo(30, UBound(CInfo) + 1) > NodetoSet = CInfo ' What is this doing. Is it > copying data from BINFO to NodetoSet why? Shouldn't it treat as a > pointer?? > End If > UpperBound = UBound(NodetoSet, 2) - 1 > 'doing stuff with NodeToSet > NodeToSet(UpperBound,1) = "hello" > NodeToSet(UpperBound,1) = "goodbye" 'And so on.... > Next > Thanks in advance > I see some issue that may help you. 1. 'Dim BInfo(,) As Object 'passed in byref Objects will always be passed by reference. Only native data types are able to be passed by value. 2. NodetoSet = BINFO This is setting NodetoSet to the same as Binfo. They both point to the same data object now. Hope this helps. Chris
master volume control in winmm using namespaces
How to get worksheet names from an excel file? Problem with Structures using FieldOffset -- BUG? Changing default printer..... Is Office required on End user's PC ? VB.Net code to upsize Access DB to SQL Express? Streams, Files, Readers and Writers VB.Net vs Access vs Deployment GraphicsPath intersections Any way to get Windows to refresh the notify area? |
|||||||||||||||||||||||