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

How is Exception Handling implemented in C#?

senior

What is scope of a Protected Internal member variable of a C# class?

senior

Can you create a function in C# which can accept varying number of arguments?

Bình luận

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

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