C# String ToUpper() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

In C#, ToUpper() returns a copy of the string with every letter in uppercase. Characters without case, such as digits and punctuation, are copied unchanged. The original string stays the same.

With no argument it uses the current culture. You can also pass a CultureInfo. For text that code compares or stores, prefer ToUpperInvariant(), which gives the same result on every computer.

This is an instance member of System.String. Call it on a string variable, such as text.ToUpper(...). Calling it on a null variable throws NullReferenceException. C# strings are immutable: ToUpper() never changes the original text. It gives back a new string (or the same one when there is nothing to change), so keep the result in a variable.

Syntax

Call it with no argument, or pass a culture.

C#
using System.Globalization;

string s = "hello, c#";
string a = s.ToUpper();                               // "HELLO, C#"
string b = s.ToUpper(CultureInfo.InvariantCulture);   // "HELLO, C#"
CallWhat it does
text.ToUpper()Uppercase using the current culture.
text.ToUpper(CultureInfo.InvariantCulture)Uppercase with fixed rules (same as ToUpperInvariant()).
char.ToUpper(name[0]) + name.Substring(1)Capitalize only the first letter.

On a Turkish system, the lowercase i becomes a dotted capital İ (U+0130), so "india".ToUpper() returns "İNDİA" there. That is correct for Turkish readers but wrong for code that expects "INDIA". For codes and keys, use the invariant version.

Library declarations
C#
public string ToUpper();
public string ToUpper(CultureInfo? culture);

Parameters

ParameterDescription
cultureOptional. The culture whose casing rules to use. null means the current culture.

Return Value

Return ValueDescription
stringAn uppercase copy of the string.

C# Examples

Example 1 — Shout It: Make an Uppercase Copy

Uppercase a short phrase, then show the original is still lowercase.

C#
using System;

class Program {
    static void Main() {
        string s = "hello, c#";
        string loud = s.ToUpper();

        Console.WriteLine(loud);
        Console.WriteLine(s);
    }
}

How It Works

  1. Every letter. h, e, l, o, and c all become capitals.
  2. Symbols unchanged. The comma, the space, and the # are copied as they are.
  3. Culture-safe text. The phrase has no lowercase i, so even a Turkish system prints the same thing.
  4. Original kept. s still holds lowercase text after the call.

Example 2 — Capitalize the First Letter of a Name

Uppercase only the first character and keep the rest, using two different ways.

C#
using System;

class Program {
    static void Main() {
        string name = "sam";
        string a = char.ToUpper(name[0]) + name.Substring(1);
        Console.WriteLine(a);

        string other = "rosa";
        string b = other.Substring(0, 1).ToUpper() + other.Substring(1);
        Console.WriteLine(b);
    }
}

How It Works

  1. Way one: one char. name[0] is 's', and char.ToUpper turns it into 'S'.
  2. Glue the rest. Substring(1) is am. Adding a char to a string gives a string: Sam.
  3. Way two: one-letter string. Substring(0, 1) copies "r", which ToUpper() turns into "R".
  4. Empty names crash. Both ways fail on "", because there is no index 0. Check string.IsNullOrEmpty first in real code.

Example 3 — Uppercase a Country Code with Fixed Rules

A word with a lowercase i is the risky case. Use the invariant culture to get the same capitals everywhere.

C#
using System;
using System.Globalization;

class Program {
    static void Main() {
        string country = "india";

        string code = country.ToUpper(CultureInfo.InvariantCulture);
        Console.WriteLine(code);
        Console.WriteLine(code == country.ToUpperInvariant());
    }
}

How It Works

  1. The risky letter. india has two lowercase is. Under Turkish rules each would become İ with a dot.
  2. Invariant gives plain I. With CultureInfo.InvariantCulture, the result is INDIA on every machine.
  3. Same as the short form. ToUpperInvariant() produces identical text, so the comparison is True.
  4. Rule of thumb. Current culture for messages people read; invariant for anything a program matches, saves, or sends.

Frequently Asked Questions

It returns a new string with all letters converted to uppercase using the current culture. The original string is not changed.
Use char.ToUpper(s[0]) + s.Substring(1) after checking that s is not empty. For title case of several words, TextInfo.ToTitleCase is an option.
ToUpper() follows the current culture, so some letters can differ between computers. ToUpperInvariant() uses fixed rules and always gives the same result.
Under the Turkish culture, lowercase i uppercases to İ (with a dot). Use ToUpperInvariant() when the result must be plain I.
No. Strings are immutable. ToUpper returns a new string, so assign it to keep it.

Next: ToUpperInvariant()

Get an uppercase copy using fixed invariant rules that are the same on every machine.

ToUpperInvariant() tutorial →

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.

14 people found this page helpful