Back to course

String Manipulation and Formatting

.NET Zero to Hero: Master C# and Modern App Development

Working with Strings

Strings in C# are powerful. Here are key techniques:

1. Interpolation (Recommended):

csharp string firstName = "John"; string lastName = "Doe"; string msg = $"My name is: {firstName} {lastName}";

2. Built-in Methods:

  • text.ToUpper() / text.ToLower()
  • text.Contains("word")
  • text.Length
  • text.Substring(0, 5)

3. Escaping:

Use \ to include special characters like \" or \n.