A string is the type that handles text data. It's commonly used to store things like usernames, emails, messages, product titles, and search keywords. C# strings come with plenty of useful methods, which makes text processing easy.
csharp
string userName = " thuta tech ";
string cleanName = userName.Trim();
Console.WriteLine(cleanName.ToUpper());
Console.WriteLine($"Length: {cleanName.Length}");
Console.WriteLine($"Contains tech: {cleanName.Contains("tech")}");What this code does
Trim()strips spaces from the start and end of the text.ToUpper()converts all letters to uppercase.Lengthreturns the number of characters.Contains()checks whether a given piece of text is present.
You should see
THUTA TECH Length: 10 Contains tech: TrueInfo
⚠️ Common mistake
Uppercase and lowercase can matter a lot in C# string comparisons. "Tech" and "tech" aren't treated as equal. If your search logic needs to be case-insensitive, convert both sides with ToLower() before comparing.