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
  • Learn & ask questions
Solved

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

Posted on 2011-02-25
9
593 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

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!
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…

856 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