What is string.ToUpper() in C#?

The ToUpper() function converts a string to uppercase.

The following figure shows a visual representation of the ToUpper() function.

Figure 1: Visual representation of ToUpper() function

Syntax

string_name.ToUpper()

string_name is the name of the string which is to be converted to uppercase

Parameter

The ToUpper() function does not require a parameter.

Return value

The ToUpper() function returns a string that is converted to uppercase.

Code

class String
{
static void Main()
{
//string
System.Console.WriteLine("('educative').ToUpper(): "+ ("educative").ToUpper());
//string with number
System.Console.WriteLine("('educative09').ToUpper(): "+ ("educative09").ToUpper());
}
}
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources