how to keep a reference to an object?

B

buu

It's dummy question, I know, but wanna be sure...

is this a proper way to keep a reference to an object:


public class Class1

private o1 as Object1
public sub New(byref vO as object1)
o1=vO
end sub
end class



on this way we keep just a reference to a object (32-bit) or we create a new
one?
 
M

Mattias Sjögren

on this way we keep just a reference to a object (32-bit) or we create a new

You just copy the reference, no new object is created (assuming
object1 is a reference type). There's no need to make v0 a ByRef
parameter.


Mattias
 
M

Mattias Sjögren

how do you mean that 'there's no need to make a byref param'?

I mean your code will work just as well (and the code will make more
sense IMO) if you change

public sub New(byref vO as object1)

to

public sub New(byval vO as object1)


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top