C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Main: The 4 calls to char.ToLower show how this static method is used. The comments show the values returned by char.ToLower.
Next: The 4 calls to char.ToUpper show how this method is used. The result from each call is shown.
StaticFinally: The last statement in the code example is the most complex and it is a call to WriteLine with a format string.
Consolestring.FormatC# program that uses char.ToLower
using System;
class Program
{
static void Main()
{
char c1 = 'a'; // Lowercase a
char c2 = 'b'; // Lowercase b
char c3 = 'C'; // Uppercase C
char c4 = '3'; // Digit 3
char lower1 = char.ToLower(c1); // a
char lower2 = char.ToLower(c2); // b
char lower3 = char.ToLower(c3); // c [changed]
char lower4 = char.ToLower(c4); // 3
char upper1 = char.ToUpper(c1); // A [changed]
char upper2 = char.ToUpper(c2); // B [changed]
char upper3 = char.ToUpper(c3); // C
char upper4 = char.ToUpper(c4); // 3
Console.WriteLine("{0},{1},{2},{3}\n" +
"{4},{5},{6},{7}\n" +
"{8},{9},{10},{11}",
c1, c2, c3, c4,
lower1, lower2, lower3, lower4,
upper1, upper2, upper3, upper4);
}
}
Output
a,b,C,3
a,b,c,3
A,B,C,3
Tip: These four static methods use value semantics, which means the parameter is copied to the method as a value.
Therefore: The ToLower and ToUpper methods do not modify the variable you use—they return a new value.
So: If you deploy your app to a customer in Turkey, all the letters will be lowercase the same as in India.