In this post, we are going to explore the Char.ToUpperInvariant(Char) method in C# along with its syntax and illustrations.
What is the Char.ToUpperInvariant Method?
The Char.ToUpperInvariant function applies standard invariant formatting guidelines to transform a Unicode character's value into its uppercase version.
The sole parameter required by this function is the character intended for conversion to uppercase, resulting in the uppercase representation based on the language's conventions.
Syntax:
It has the following syntax:
public static char ToUpperInvariant ( char c )
where c is the Unicode character to convert.
Return Value:
The function's output is as follows:
- If c is already in uppercase or non-alphabetic, it will stay the same.
- Otherwise, it will return the uppercase version of the c parameter.
Program 1:
Let's consider a scenario to demonstrate the functionality of the Char.ToUpperInvariant method in the C# programming language.
using System;
class ABC {
public static void Main()
{
// calling get() Method
get('P');
get('p');
get('Q');
get('q');
get('-');
}
public static void get(char c)
{
// getting Unicode character by using the ToUpperInvariant() Method
char val = Char.ToUpperInvariant(c);
// shows the char value
Console.WriteLine("The uppercase equivalent"+
" of the {0} is {1}", c, val);
}
}
Output:
The <style> element defines a CSS class for a diagram with a specific styling. The diagram has a background color created with a linear gradient, a border with rounded corners, padding, margin, and centered text alignment. Inside the diagram, there is an icon with a larger font size and some text with a smaller font size and a different color. This class can be applied to elements to give them a consistent visual representation.
Program 2:
Let's consider another instance to demonstrate the functionality of the Char.ToUpperInvariant method in C#.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
Char[] chars = {'a', 'A', 'b', 'B' };
foreach (var ch in chars) {
Console.Write(Char.ToUpperInvariant(ch));
}
}
}
Output: