C# Convert Int to Char

Harshit Jindal Jan 30, 2023 Feb 09, 2022
  1. Use Explicit Type Cast Char to Cast Int to Char in C#
  2. Use Convert.ToChar() Method to Cast Int to Char in C#
C# Convert Int to Char

This tutorial will look at different casting methods to cast int to char in C#.

You can check how to convert char to int in C# in this article.

Use Explicit Type Cast Char to Cast Int to Char in C#

The explicit type cast by typing the name of the type is the most general and prevalent method used across all languages. The below code shows a C# demonstration of the same.

using System;

public class Program
{
	public static void Main()
	{
		Console.WriteLine("(char)102 is {0}", (char)102);
	}
}

Output:

(char)102 is f

In the above example, we demonstrate how to typecast int to char in C#.

Use Convert.ToChar() Method to Cast Int to Char in C#

C# provides an explicit method for type conversion to char Convert.ToChar(). We can pass the integer to be typecasted as an argument, and the method will return the corresponding char.

using System;

public class Test
{
	public static void Main()
	{
		int i = 65;
		char c = Convert.ToChar(i);
		Console.WriteLine(c);
	}
}

Output:

A

Related Article - Csharp Data Type