C# String Methods

Beginner
6 min read
Updated: Nov 2026
50 method guides
Method index

About This Index

This page is the C# String Methods index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn what a string is on /c-sharp/string. Use this page when you need a specific API such as Contains(), Equals(), or Format().

Beginner path.

Start with Contains(), IndexOf(), Substring(), Split(), Replace(), and Trim(), then browse the rest by category. Every method that seems to “change” a string really returns a new one.

How to Call a String Method

Instance methods use a dot; static helpers use the class name:

C#
string text = "Hello, C#!";

// Instance
bool hasCs = text.Contains("C#");
bool isCs  = text.EndsWith("C#!");
bool same  = text.Equals("Hello, C#!");

// Static
string joined = String.Concat("Hi", ", ", "C#");
string msg    = String.Format("Count: {0}", 3);

C# String Methods Table

All method guides in this C# tutorial series (50 tutorials).

Clone, copy & convert

6 methods

Duplicate a string, copy its characters into an array or span, or get the string back as itself.

MethodDescriptionTutorial
Clone()ICloneable; returns same string instance.Try it
Copy()Static: new string with same chars.Try it
CopyTo()Copy chars into a char array.Try it
TryCopyTo()Copy into a Span<char> if it fits (bool).Try it
ToCharArray()Copy chars into a new char[] you can edit.Try it
ToString()Returns the same string instance.Try it

Build & format

5 methods

Join pieces into one string, fill a template, insert text, or build a string directly in memory.

MethodDescriptionTutorial
Concat()Join two or more strings.Try it
Format()Composite-format templates.Try it
Join()Static: glue items with a separator.Try it
Insert()Put text in at a position (new string).Try it
Create()Static: fill a new string's chars directly (advanced).Try it

Comparison & ordering

4 methods

Equality, culture rules, ordinal order, and IComparable results.

MethodDescriptionTutorial
Compare()Static culture-aware comparison.Try it
CompareOrdinal()Static ordinal (code-point) order.Try it
CompareTo()Instance IComparable comparison.Try it
Equals()Content equality check.Try it

Search & match

7 methods

Check whether text starts with, ends with, or includes something, and find the position of a character or substring.

MethodDescriptionTutorial
Contains()Substring present anywhere?Try it
StartsWith()Prefix match at the start.Try it
EndsWith()Suffix match at the end.Try it
IndexOf()First position of a char or substring (-1 if missing).Try it
IndexOfAny()First position of any char from a set.Try it
LastIndexOf()Last position of a char or substring (-1 if missing).Try it
LastIndexOfAny()Last position of any char from a set.Try it

Cut, edit & split

7 methods

Take part of a string, remove or replace text, split it into pieces, or line it up with padding. Each call returns a new string.

MethodDescriptionTutorial
Substring()Copy part of a string by position and length.Try it
Remove()Delete chars from a position (new string).Try it
Replace()Swap every match for new text (new string).Try it
ReplaceLineEndings()Make all line breaks the same (.NET 6+).Try it
Split()Break into an array at separators.Try it
PadLeft()Fill on the left to a width (right-align).Try it
PadRight()Fill on the right to a width (left-align).Try it

Trim

3 methods

Remove spaces or chosen characters from the start, the end, or both ends.

MethodDescriptionTutorial
Trim()Remove spaces or chars from both ends.Try it
TrimStart()Remove spaces or chars from the start.Try it
TrimEnd()Remove spaces or chars from the end.Try it

Upper & lower case

6 methods

Change letter case with the current culture or with fixed invariant rules. The Ordinal pages explain what to use, because no such built-in method exists.

MethodDescriptionTutorial
ToLower()Lowercase copy (current culture).Try it
ToLowerInvariant()Lowercase copy (invariant, same everywhere).Try it
ToLowerOrdinal()Not a built-in method: use these instead.Try it
ToUpper()Uppercase copy (current culture).Try it
ToUpperInvariant()Uppercase copy (invariant, same everywhere).Try it
ToUpperOrdinal()Not a built-in method: use these instead.Try it

Null & empty checks

2 methods

Static tests that catch null, empty, and blank strings in one call.

MethodDescriptionTutorial
IsNullOrEmpty()Static: null or "" in one test.Try it
IsNullOrWhiteSpace()Static: null, "", or only white space.Try it

Unicode & normalization

3 methods

Walk whole Unicode characters (runes) and make accented text compare the same way.

MethodDescriptionTutorial
EnumerateRunes()Loop over whole Unicode characters (runes).Try it
Normalize()Put Unicode text into a standard form.Try it
IsNormalized()Is the text already in a normal form?Try it

String pool (interning)

2 methods

Share one copy of repeated text through the runtime string pool.

MethodDescriptionTutorial
Intern()Static: get the pooled, shared copy.Try it
IsInterned()Static: pooled copy or null (never adds).Try it

Enumeration & metadata

5 methods

Iterate characters, compute hash codes, inspect runtime type information, and low-level pinning support.

MethodDescriptionTutorial
GetEnumerator()foreach over characters.Try it
GetHashCode()Hash code for collections.Try it
GetType()Runtime Type of instance.Try it
GetTypeCode()TypeCode enum for the value.Try it
GetPinnableReference()Low-level support for fixed (not for daily use).Try it

Frequently Asked Questions

String methods are built-in operations on System.String for comparing text, searching substrings, joining strings, formatting output, copying characters, and reading metadata. Call most of them on a string variable: text.Contains("C#").
The Strings page teaches what a string is—literals, interpolation, Length, and immutability. This Methods index lists every method tutorial so you can open Contains(), Equals(), Format(), and the rest.
Use dot notation on a string instance: str.Contains("test"), str.EndsWith(".cs"). Static helpers use String or string: String.Compare(a, b), String.Concat(parts), String.Format("{0}", value).
No. Methods like Replace(), Trim(), Substring(), ToUpper(), Concat(), and Format() return new strings; the original never changes. For frequent edits in loops, use StringBuilder.
If you are new, read C# Strings first. Then open Contains(), IndexOf(), Substring(), Split(), Replace(), and Trim() from the tables below.

Start with Contains()

Open the first search method guide—syntax, examples, and FAQs.

Contains() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful