Char.ToString() Method in C#


The Char.ToString() method in C# is used to convert the value of this instance to its equivalent string representation.

Syntax

Following is the syntax −

public override string ToString ();

Example

Let us now see an example to implement the Char.ToString() method −

using System;
public class Demo {
   public static void Main(){
      char ch = 'p';
      Console.WriteLine("Value = "+ch);
      char res1 = Char.ToLowerInvariant(ch);
      Console.WriteLine("Lowercase Equivalent = "+res1);
      string res2 = ch.ToString();
      Console.WriteLine("String Equivalent = "+res2);
   }
}

Output

This will produce the following output −

Value = p
Lowercase Equivalent = p
String Equivalent = p

Example

Let us now see another example −

using System;
public class Demo {
   public static void Main(){
      char ch = 'D';
      Console.WriteLine("Value = "+ch);
      char res1 = Char.ToLowerInvariant(ch);
      Console.WriteLine("Lowercase Equivalent = "+res1);
      string res2 = ch.ToString();
      Console.WriteLine("String Equivalent = "+res2);
   }
}

Output

This will produce the following output −

Value = D
Lowercase Equivalent = d
String Equivalent = D

Updated on: 07-Nov-2019

84 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements