Hi all,
what does type String is immutable mean?
I did an assignment on that:
string s;
s = "car";
s += "bus"....
And then,
StringBuilder sb = new StringBuilder(10);
sb.Append("car")
sb.Append("bus")
But both give the same result.
It is said that StringBuilder is there to create dynamic strings.
But I feel like we can use string to do the same thing with out any issue.
- Can anyone give me a good example to differentiate between string and stringbuilder?
- What is the difference between String and StringBuilder?
- Why Strings are immutable?
- Why we use new key word only to declare StringBuilder and not with string declaration?
Please help me to resolve this.
Thanks and Regards,
Jay.