Link to home
Start Free TrialLog in
Avatar of Parth48
Parth48Flag for India

asked on

how can i convert ascii value to character and then storing it to string ??

i want to know that how can i convert ascii value to character and then storing it to string ??

for ex ..

int i = 97 then

string str = "a"

but how can i do this ??
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I propose

int i = 97;
string str = Convert.ToChar(i);
int i = 97
string str = Convert.ToChar(i).ToString() ;
Avatar of TinTombStone
TinTombStone

I think convertFromUtf32() is the best option.

    class Program
    {
        static void Main(string[] args)
        {
            int i = 97;
            string ch = char.ConvertFromUtf32(i);
            Console.WriteLine(ch);
        }
    }
use following method for this :

static String ConvertAsciiToString(int number)
        {
            string stringValue = char.ConvertFromUtf32(number).ToString();
            return stringValue;
        }

or 

static String ConvertAsciiToString(int number)
        {
            string stringValue = new string((char)number, 1);
            return stringValue;
        }

Open in new window

hey I tried Dhaest that solution giving error

'char' does not contain a definition for 'ConvertFromUtf32'

is it working for you ?

int i = 97;
string str = char.ConvertFromUtf32(i);
ok Dheast . might be it is becae I am using old .net version
Whate .net version are you using ?