Reputation: 4010
in Java passing StringBuilders to methods seems it's passing by Reference but in C# it seems it's passing by value, is it like this? do you think it may work only with ref keyword? what're the differences overall?
Upvotes: 0
Views: 1989
Reputation: 10588
A StringBuilder
is an object, so whether you pass the reference to it by reference or by value, doesn't matter at all. Java only has pass-by-value. If you pass the reference to it by reference, you are able to change the original reference from the method, that't the only difference. The object you reference is always changed whether you send the reference to it by value or by reference.
Why do you think there is a difference? Do you have any example code that seems to indicate there is a difference?
Upvotes: 4