Files
CSharp-learning/C# Full Course for free/7.Strings methods.md
2026-01-13 03:16:55 +01:00

864 B

String method

ToUpper

set strings uppercase

String fullName = "mrsh"; 
fullName = fullName.ToUpper();

Tolower

set strings lowercase

String fullName = "mrsh"; 
fullName = fullName.ToLower();

Replace

String phoneNumber = "123-456-789"; 
phoneNumber.Replace("-", "/");

Insert

String fullName = "mrsh online"; 
userName = fullName.Insert(0, "@");

Length

String fullName = "mrsh online"; 
fullName.Length();

Substring

String fullName = "mrsh online"; 
String firstName = fullName.Substring(0,4); 
String lastName = fullName.Substring(5,6); 

String interpolation

String firstName = "mrsh";
String lastName = "Online";
int age = 21;

Console.WriteLine($"Hello {firstName} {lastName}.");

// include 10 spaces
Console.WriteLine($"You are {age, 10} years old.");