Parth48
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 ??
for ex ..
int i = 97 then
string str = "a"
but how can i do this ??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
int i = 97
string str = Convert.ToChar(i).ToString () ;
string str = Convert.ToChar(i).ToString
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);
}
}
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;
}
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);
'char' does not contain a definition for 'ConvertFromUtf32'
is it working for you ?
int i = 97;
string str = char.ConvertFromUtf32(i);
I just retried it here ... and it's working for me.
http://msdn.microsoft.com/en-us/library/system.char.convertfromutf32.aspx
convertfromutf32.JPG
http://msdn.microsoft.com/en-us/library/system.char.convertfromutf32.aspx
convertfromutf32.JPG
ok Dheast . might be it is becae I am using old .net version
Whate .net version are you using ?
int i = 97;
string str = Convert.ToChar(i);