## Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

• Help others & share knowledge
• Earn cash & points
Solved

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

Posted on 2011-02-25
593 Views
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 ??
0
Question by:Parth48

LVL 53

Accepted Solution

Dhaest earned 500 total points
ID: 34978766
Did you try the following

int i = 97;
string str = char.ConvertFromUtf32(i);
0

LVL 10

Expert Comment

ID: 34978809
I propose

int i = 97;
string str = Convert.ToChar(i);
0

LVL 39

Expert Comment

ID: 34978830
int i = 97
string str = Convert.ToChar(i).ToString() ;
0

LVL 6

Expert Comment

ID: 34978849
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);
}
}
0

LVL 13

Expert Comment

ID: 34978857
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;
}
``````
0

LVL 39

Expert Comment

ID: 34979016
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);
0

LVL 53

Expert Comment

ID: 34979049
0

LVL 39

Expert Comment

ID: 34979144
ok Dheast . might be it is becae I am using old .net version
0

LVL 53

Expert Comment

ID: 34979157
Whate .net version are you using ?
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Starting up a Project
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…