C# Exception Handling
C# File I/O
C# Delegates and Events
C# Generics
C# Async Programming
C# String Methods

C# String Methods

The System.String class has dozens of built-in methods for searching, transforming, and splitting strings.

1 - Common Methods

string s = "  Hello, World!  ";

s.Length;                   // 18
s.Trim();                   // "Hello, World!"
s.TrimStart();              // "Hello, World!  "
s.TrimEnd();                // "  Hello, World!"
s.ToUpper();                // "  HELLO, WORLD!  "
s.ToLower();                // "  hello, world!  "
s.Replace("World", "C#");  // "  Hello, C#!  "

2 - Searching

string str = "C# is a modern language";

str.Contains("modern");          // true
str.StartsWith("C#");            // true
str.EndsWith("language");        // true
str.IndexOf("modern");           // 9
str.LastIndexOf("a");            // 21

3 - Splitting and Joining

string csv = "Alice,Bob,Carol";
string[] parts = csv.Split(