Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ByRef argument acting like a ByVal
Message
From
12/05/2011 18:16:33
 
 
To
12/05/2011 17:51:41
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
Miscellaneous
Thread ID:
01510491
Message ID:
01510513
Views:
49
>>>>I have a method that have the last few arguments being passed by reference (ByRef). But after the methods ends, the value returned do not have the changes applied by the methods. What would cause a string to be passed as though it was by value and not by reference. ( There are other methods with arguments being passed by reference and they work fine - I think).
>>>
>>>
>>>See the discussion here. String is an immutable reference type.
>>
>>Ok, do you have a link?
>
>
>Sorry Greg, I was late for a meeting.
>
>Here it is
>
>http://stackoverflow.com/questions/3655984/why-is-string-a-reference-type


However, in a quick test, if I pass in a string ByRef and modify the string in the sub, that modification is reflected in the caller. Just like you expected. Weirder still, if you pass in a string ByVal, it behaves like a Value Type, even though most reference types are modified in a method even if passed ByVal.
Previous
Reply
Map
View

Click here to load this message in the networking platform