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

junior

What is Managed or Unmanaged Code?

middle

Why can't you specify the accessibility modifier for methods inside the Interface?

junior

What is Serialization?

Bình luận

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

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