473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Formatting int as a ASCII char

13
Hello,

I must present integers as a ASCII chars.
For instance for num 65 -> str1 "A".
int num = 65;
string str1 = String.Format("{0:??}",num);

Mentioned problem cannot be solved with Encoding.ASCII... and others, because of the fact that I use specified "C# like" environment with only String.Format method for that.

I would be grateful for Your help.
Thanks a lot!

pb2000
Mar 2 '12 #1
1 1850
GaryTexmo
1,501 Expert 1GB
Try casting the int to a char and appending to a string.

Expand|Select|Wrap|Line Numbers
  1.             int aCode = 65;
  2.  
  3.             string resultStr = "" + (char)aCode;
  4.  
  5.             Console.WriteLine(resultStr);
Mar 2 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Director - Minvent | last post by:
Hi, I am reading from a serial port from a device which sends over an ascii character. It uses the full extended 256 character set and therefore has non-printing characters too. So what i want...
2
by: loki | last post by:
hello, when i do ..... set xmlhttp = CreateObject("WinHTTP.WinHTTPRequest.5.1") ...... StrXmlhttpResponseText = xmlhttp.responseText StrXmlhttpResponseText = replace(StrXmlhttpResponseText,...
1
by: Sagaert Johan | last post by:
Hi I am construncting a string containing some control chars (STX/ETX) I noticed that adding a byte with value 2 is the same as adding a character '2' ??? How can i solve this problem ?...
2
by: Director - Minvent | last post by:
I am reading values from a comm port and recieve individual ascii characters including non-printing and extended ones. They span the entire range from dec value 0 to 255. What I need to do is get...
2
by: dotnetchic | last post by:
I'm trying to parse a binary file to help me with some analysis...what I'd like to do is take a byte of data and display its ascii char value (37='%', 38='&', etc.). private void...
1
by: neoswf | last post by:
hi all i have this function: -- function userNameValidChars(e) { if (!e) var e = window.event; if (e.keyCode) key = e.keyCode; else if (e.which) key = e.which; if(!(key==37) && !(key==39))...
1
by: Binu C | last post by:
Can any1 pls tell me how to convert contents in text file(ie., notepad) which includes alphabets & char into ASCII code & write into another text file
6
by: Aneesh E Warrier | last post by:
How can I convert Unicode Codepoint (dec) value to ASCII char? For example: 49324 is 사 a Korean alphabet, and I want to convert it to ASCII letter. Thanks!
2
by: Jcan | last post by:
hi I have a long variable: long id = 0x0457; which in decimal is 1111 I need to convert id into a char array with its ascii values.
1
by: jmelech | last post by:
String hello = "james"; int ascii; char letter = hello.toCharArray(); int j = letter.getLength(); for(int i = 0; i<=j; i++){ ascii = (int) letter; } ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.