Solved

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

Posted on 2011-02-25
9
592 Views
Last Modified: 2012-05-11
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
Comment
Question by:Parth48
9 Comments
 
LVL 53

Accepted Solution

by:
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

by:John Claes
ID: 34978809
I propose

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

Expert Comment

by:Pratima Pharande
ID: 34978830
int i = 97
string str = Convert.ToChar(i).ToString() ;
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 6

Expert Comment

by:TinTombStone
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

by:Naman Goel
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;
        }

Open in new window

0
 
LVL 39

Expert Comment

by:Pratima Pharande
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

by:Dhaest
ID: 34979049
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 34979144
ok Dheast . might be it is becae I am using old .net version
0
 
LVL 53

Expert Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question