C# में ToLower () विधि का उपयोग इस स्ट्रिंग की एक कॉपी को लोअरकेस में बदलने के लिए किया जाता है।
सिंटैक्स
वाक्य रचना इस प्रकार है -
public string ToLower ();
उदाहरण
आइए अब एक उदाहरण देखें -
using System; public class Demo { public static void Main(String[] args) { string str1 = "WELCOME!"; string str2 = "Thisisit!"; char[] arr1 = str1.ToCharArray(3,2); char[] arr2 = str2.ToCharArray(2,2); Console.WriteLine("String1 = "+str1); Console.WriteLine("String1 ToLower = "+str1.ToLower()); Console.WriteLine("String1 Substring from index4 = " + str1.Substring(4, 4)); Console.Write("Character array...String1 ="); for (int i = 0; i < arr1.Length; i++) Console.Write(" " + arr1[i]); Console.WriteLine("\n\nString2 = "+str2); Console.WriteLine("String2 ToLower = "+str2.ToLower()); Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5)); Console.Write("Character array...String2 ="); for (int i = 0; i < arr2.Length; i++) Console.Write(" " + arr2[i]); } }
आउटपुट
String1 = WELCOME! String1 ToLower = welcome! String1 Substring from index4 = OME! Character array...String1 = C O String2 = Thisisit! String2 ToLower = thisisit! String2 Substring from index2 = Thisi Character array...String2 = i s
उदाहरण
आइए अब एक और उदाहरण देखें -
using System; using System.Globalization; public class Demo { public static void Main(String[] args) { string str1 = "ABCD!"; string str2 = "@#$PQRSTUV!"; Console.WriteLine("String1 = "+str1); Console.WriteLine("String1 ToLower = "+str1.ToLower(new CultureInfo("en-US", false))); Console.WriteLine("String1 Substring from index4 = " + str1.Substring(2, 2)); Console.WriteLine("\n\nString2 = "+str2); Console.WriteLine("String2 ToLower = "+str2.ToLower(new CultureInfo("en-US", false))); Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5)); } }
आउटपुट
String1 = ABCD! String1 ToLower = abcd! String1 Substring from index4 = CD String2 = @#$PQRSTUV! String2 ToLower = @#$pqrstuv! String2 Substring from index2 = @#$PQ