Friday, 29 August 2014

How to Convert Char to Int and Vice Versa in C#

using System;
class Program
{
    static void Main()
    {
        //converting char to int
        int i;
        Console.WriteLine("Enter any Number:");
        i = int.Parse(Console.ReadLine());
        char c = Convert.ToChar(i);
        Console.WriteLine(c);
        Console.ReadLine();


        //converting int to char
        char k;
        Console.WriteLine("Enter any Char:");
        k = char.Parse(Console.ReadLine());
        int m = Convert.ToInt32(k);
        Console.WriteLine(m);
        Console.ReadLine();

    }


}

How to Convert Char to Int
output


No comments:

Post a Comment