Câu hỏi phỏng vấn C#
Câu hỏi

What is the difference between string and StringBuilder in C#?

Câu trả lời

Here is the difference between string and StringBuilder in C#:

String

  • Strings in C# are immutable, meaning once a string is created, its value cannot be changed.
  • When you modify a string, a new string object is created in memory and the old one is discarded.
  • Strings are allocated on the heap and are thread-safe.
  • Strings are efficient for small amounts of text that don't change frequently.

StringBuilder

  • StringBuilder is a mutable string type that allows you to modify the contents of a string without creating a new object.
  • It is optimized for appending, inserting, or removing characters from a s...
junior

junior

Gợi ý câu hỏi phỏng vấn

expert

What is jagged array in C# and when to prefer jagged arrays over multi-dimensional arrays?

entry

What is C#?

junior

What are dynamic type variables in C#?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào