Strings in C#

 String is an object of System.String class that represents sequence of characters

  • In C# 'string' is a keyword which is an alias for system.String class
  • The literal string becomes a template when it's prefixed by the $ character, the thing is called string interpolation
    • e.g.
      string message = $"{greeting} {firstName}! Good Morning";

String methods (System.String)

  • Clone
  • CompareTo : Returns integer 
  • Contains
  • EndsWith
  • Equals : Returns boolean
  • ToUpper
  • ToLower
  • Insert
  • IndexOf
  • Concat : It's a static method


StringBuilder example:


*StringBuilder class have differnet methods then System.String class e.g. Append etc.



Comments