Sobes.tech
Junior — Middle

Can you tell about the key features of string data in programming?

sobes.tech AI

Answer from AI

In C#, strings (string) have several key features:

  • Immutability: once created, a string cannot be changed. Any operation that modifies a string creates a new object.
  • Unicode support: strings store characters in UTF-16 format, allowing work with a wide range of symbols.
  • Comparison: strings are compared by content, not by reference, which is convenient for equality checks.
  • Interning: the compiler can store identical string literals in one place to save memory.
  • Methods and properties: the string class provides many methods for text manipulation — searching, replacing, splitting, case conversion, etc.

Example usage:

string s = "Example string";
string upper = s.ToUpper(); // "EXAMPLE STRING"
bool contains = s.Contains("string"); // true