• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 631
  • Last Modified:

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 ??
0
Parth48
Asked:
Parth48
1 Solution
 
DhaestCommented:
Did you try the following

int i = 97;
string str = char.ConvertFromUtf32(i);
0
 
John ClaesSenior .Net Consultant & Technical AnalistCommented:
I propose

int i = 97;
string str = Convert.ToChar(i);
0
 
Pratima PharandeCommented:
int i = 97
string str = Convert.ToChar(i).ToString() ;
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
TinTombStoneCommented:
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
 
Naman GoelSoftware engineer 1Commented:
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

0
 
Pratima PharandeCommented:
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
 
DhaestCommented:
0
 
Pratima PharandeCommented:
ok Dheast . might be it is becae I am using old .net version
0
 
DhaestCommented:
Whate .net version are you using ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now