C# String

Explore string methods: create, search and change strings with built-in code.

String. You look into a reflecting pool. A message suddenly appears. It is a string written upon the water's surface. Strings have words and characters.

String methods. Usually strings do not appear in reflecting pools. But we can manipulate any C# string with methods. New strings are returned.

String interpolation. A string can be created with interpolated values in it. This is similar to string.Format but the syntax is different. We precede the string literal with a "$" sign.

Constructor. Strings are often reused, and passed around within a program. Methods like Replace() create new strings. But we can also create new ones with a constructor.

Literals. These specify string data. We use quotes around literal data (characters). Literals are embedded in the program executable.

Comparisons. Are two strings equal? In a Dictionary, we can use a StringComparer to change how keys are compared. We can ignore case.

Char. A string contains data made up of individual characters. We deal with these chars in looping constructs. Accessing chars is a fast way to test strings.

TextInfo. This type provides some helpful methods. We can convert a string To Title Case with ToTitleCase. No custom methods are needed.