string is immutable and stringbuilder is mutable

前端 未结 8 1304
轻奢々
轻奢々 2020-12-06 08:38

can any one explain with examples


Related Discussion: Most efficient way to concatenate strings?

8条回答
  •  抹茶落季
    2020-12-06 09:19

    Some of the reasons why they have been made immutable:

    • Immutable types are thread safe meaning you can pass a string around without worrying it's been changed.
    • Security is much more of a concern if strings can be changed.

提交回复
热议问题