Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ByVal and ByRef

Reply
Thread Tools

ByVal and ByRef

 
 
Goncalo
Guest
Posts: n/a
 
      12-04-2003
Hi.

Can you tell me what's the difference between ByVal and
ByRef in VB.Net.

I'm asking this 'cause i'm passing an object into a
function ByVal, then I change that object and when the
function terminates the original object is changed.

This kind of output is usual when passing objects ByRef,
right?

Thank's in advance
Goncalo
 
Reply With Quote
 
 
 
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      12-04-2003
Hi,

For objects (that is, reference types) ByVal means that the function being
called cannot overwrite the *reference* to the object instance which is
actually passed in the parameter variable. But it does not prevent the
callee to alter properties on the instance.

ByRef, on the other hand, enables the callee to overwrite the reference
itself and therefore substitute the original object instance with another
one.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Goncalo" <(E-Mail Removed)> wrote in message
news:095a01c3ba4a$9d2f60e0$(E-Mail Removed)...
> Hi.
>
> Can you tell me what's the difference between ByVal and
> ByRef in VB.Net.
>
> I'm asking this 'cause i'm passing an object into a
> function ByVal, then I change that object and when the
> function terminates the original object is changed.
>
> This kind of output is usual when passing objects ByRef,
> right?
>
> Thank's in advance
> Goncalo


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cTor argument byVal or byRef ManicQin C++ 7 08-02-2008 09:38 PM
Byref / Byval? Rob Meade ASP .Net 5 12-28-2006 09:15 PM
custvalidator: why is args byval and not byref? xamman ASP .Net 1 12-22-2006 08:21 PM
Byval vs. byref Iams ASP .Net 5 02-24-2005 04:48 PM
Re: How to set default to TRUE: Overrides Function OnBubbleEvent(ByVal source As Object, ByVal args As EventArgs) As Boolean? David Waz... ASP .Net 0 07-04-2003 07:32 PM



Advertisments