Advertisement
Methods | Description |
---|---|
ToLower() | This method returns a lowercase copy of the invoked String object. |
ToLower(CultureInfo) | This method returns a lowercase copy of the invoked String object, by using the casing rule of the specified culture, specified by CultureInfo class. |
//Program to convert a String to lowercase letters.
using System;
class StringUpper
{
public static void Main()
{
//Creating the first String object
String str1 = "New Zealand";
//Creating a char array
char[] char = {'H', 'E', 'L', 'L', 'O'};
//Creating the second String object from a char[] array.
String str2 = new String(char);
Console.WriteLine("First String is : "+ str1);
Console.WriteLine("First String's lowercase value : " + str1.ToLower());
Console.WriteLine("Second String is : "+ str2);
Console.WriteLine("Second String's lowercase value : " + str2.ToLower());
}
}
First String is : New Zealand
First String's lowercase value : new zealand
Second String is : HELLO
Second String's lowercase value : hello
//C# Calling method ToLower() does not modify the original content of the invoked String object
using System;
class StringUpper
{
public static void Main()
{
//Creating a String object
String str1 = "Mars - The Red Planet";
//Creating a char array
char[] arr = {'E', 'a', 'r', 't', 'h'};
//Creating the second String object from a char[] array.
String str2 = new String(arr);
//Printing the value of the first String before calling ToLower() on it
Console.WriteLine("First string : "+ str1);
//Printing the lowercase copy of the first String returned by ToLower()
Console.WriteLine("First String's lowercase value : " + str1.ToLower());
//Printing the value of the first String after calling ToLower() on it.
Console.WriteLine("First string after calling ToLower() : " + str1);
//Printing the value of the second String before calling ToLower() on it
Console.WriteLine("Second string : "+ str2);
//Printing the lowercase copy of the second String returned by ToLower()
Console.WriteLine("Second String's lowercase value : " + str2.ToLower());
//Printing the value of the second String after calling ToLower() on it.
Console.WriteLine("Second string after calling ToLower() : " + str2);
}
}
First string : Mars - The Red Planet
First String's lowercase value : mars - the red planet
First string after calling ToLower() : Mars - The Red Planet
Second string : Earth
Second String's lowercase value : earth
Second string after calling ToLower() : Earth
Advertisement
//C# Calling method ToLower() does not modify the original content of the invoked String object
using System;
using System.Globalization;
class StringUpper
{
public static void Main()
{
//Creating a String object
String str1 = "Keep Working Hard For Your Dreams";
//Printing the value of the first String before calling ToLower() on it
Console.WriteLine("String : "+ str1);
//Creating an object of CultureInfo class based on the English-US culture
CultureInfo ci1 = new CultureInfo("en-us", false);
//Creating an object of CultureInfo class based on the Turkish-Turkey culture
CultureInfo ci2 = new CultureInfo("tk-TR", false);
//Creating an object of CultureInfo class based on the Turkish-Turkey culture
CultureInfo ci3 = new CultureInfo("fr-FR", false);
//Printing a lowercase copy of the first String according to English-United States culture
Console.WriteLine("String's lowercase value based on English-US culture: " + str1.ToLower(ci1));
//Printing a lowercase copy of the first String according to Turkish-Turkey culture
Console.WriteLine("String's lowercase value based on Turkish-Turkish culture: " + str1.ToLower(ci2));
//Printing a lowercase copy of the first String according to French-France culture
Console.WriteLine("String's lowercase value based on French-France culture: " + str1.ToLower(ci3));
//Extracting the current culture of our system
CultureInfo current = CultureInfo.CurrentUICulture;
Console.WriteLine("The current UI culture of our system is {0}", current.Name);
}
}
String : Keep Working Hard For Your Dreams
String's lowercase value based on English-US culture: keep working hard for your dreams
String's lowercase value based on Turkish-Turkish culture: keep working hard for your dreams
String's lowercase value based on French-France culture: keep working hard for your dreams
The current UI culture of our system is en-US
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement