C# String Methods

A C# String is a class; it provides various methods to perform different operations on strings. On this reference page, you will find all the popular string methods available in C#.

For example, the String compare() method allows us to compare two strings in sort order.

C# String LastIndexOf()

Returns index of the last occurrence of substring

C# String ToUpper()

Converts characters in the string to uppercase

C# String Compare()

Compares two strings in the alphabetical order

C# String Concat()

Concatenates (joins) strings

C# String Contains()

Checks whether the string contains a substring

C# String EndsWith()

Checks if the string ends with the given string

C# String Equals()

Checks whether two strings have the same value

C# String Format()

Returns a formatted string

C# String IndexOf()

Returns the index of the string

C# String Join()

Joins the given strings using a separator

C# String PadLeft()

Returns a new string with left padding

C# String PadRight()

Returns new string with right padding

C# String Remove()

Removes a specified number of characters

C# String Replace()

Replace all matching characters/text in the string

C# String Split()

Returns substrings of a string

C# String StartsWith()

Checks if string starts with the specified string

C# String Substring()

Returns a substring from the given string

C# String ToCharArray()

Copies characters in string to a character array

C# String ToLower()

Converts all characters in the string to lowercase

C# String Trim()

Removes any leading and trailing whitespaces