differences between passing StringBuilder to methods in Java and C#
in Java passing StringBuilders to methods seems it's passing b开发者_C百科y 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?
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?
精彩评论