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

entry

What is C#?

middle

What is the difference between Interface and Abstract Class?

expert

What's the difference between the System.Array.CopyTo() and System.Array.Clone() ?

Bình luận

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

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