By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Array Objects pointers, value types reference types??

P: n/a
Hi all,
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

Feb 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
pl*****@hotmail.com wrote:
Hi all,
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


Ok, I can't say I fully understand what you are doing here, but I think
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
Feb 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.