C# String.ToLowerInvariant Method


The String.ToLowerInvariant() method in C# is used to return a copy of this String object converted to lowercase using the casing rules of the invariant culture.

Syntax

The syntax is as follows -

public string ToLowerInvariant ();

Example

Let us now see an example -

 Live Demo

using System;
using System.Text;
public class Demo {
   public static void Main(String[] args) {
      string str1 = "Pink Floyd";
      string str2 = "Ariana";
      Console.WriteLine("String 1 = "+str1);
      Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant());
      Console.WriteLine("String 2 = "+str2);
      Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant());
      Console.WriteLine("String 1 is equal to String 2: {0}", str1.Equals(str2));
   }
}

Output

String 1 = Pink Floyd
String1 ToLowerInvariant = pink floyd
String 2 = Ariana
String2 ToLowerInvariant = ariana
String 1 is equal to String 2: False

Example

Let us now see another example -

using System;
using System.Text;
public class Demo {
   public static void Main(String[] args) {
      string str1 = "one";
      string str2 = "TWO";
      string str3 = "ThrEE";
      Console.WriteLine("String 1 = "+str1);
      Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant());
      Console.WriteLine("String 2 = "+str2);
      Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant());
      Console.WriteLine("String 3 = "+str3);
      Console.WriteLine("String3 ToLowerInvariant = "+str3.ToLowerInvariant());
   }
}

Output

This will produce the following output -

String 1 = one
String1 ToLowerInvariant = one
String 2 = TWO
String2 ToLowerInvariant = two
String 3 = ThrEE
String3 ToLowerInvariant = three
raja
Published on 03-Dec-2019 12:15:59
Advertisements