473,378 Members | 1,454 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,378 software developers and data experts.

Convert and Int32 value into a Character

Hi,
Can anyone tell me how I can convert an Intager value such as '66' into the
letter 'f' (using ANSI ASCII).

Thanx Josh
Nov 16 '05 #1
3 4544
Just cast it to char:

(char)66

Bruno.

"Joshua Russell" <joshATojmyster|DOTukDOTTeuDOOTorgNOSPAM.PLZ> a écrit dans
le message de news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
Can anyone tell me how I can convert an Intager value such as '66' into the letter 'f' (using ANSI ASCII).

Thanx Josh

Nov 16 '05 #2
<"Joshua Russell" <joshATojmyster|DOTukDOTTeuDOOTorgNOSPAM.PLZ>>
wrote:
Can anyone tell me how I can convert an Intager value such as '66' into the
letter 'f' (using ANSI ASCII).


Just cast it to char:

int i = 66;
char x = (char)i;

That will always give you the Unicode value. All ASCII characters have
the same value in Unicode.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Joshua

The integer value '66' is binary 01000010, or hex 0x42, which corresponds to
'B' in the ASCII character set. It will take a bit more than a simple cast
to make the conversion to ASCII 'f'...

However, this will work:

int ival = 0x66;
.. . .
char cval = (char)ival;
.. . .
regards
roy fine

"Joshua Russell" <joshATojmyster|DOTukDOTTeuDOOTorgNOSPAM.PLZ> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
Can anyone tell me how I can convert an Intager value such as '66' into the letter 'f' (using ANSI ASCII).

Thanx Josh

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Daniel Köster | last post by:
Is there someone who has got some tips on how to convert text encoded with character referense ({) to unicode or uft-8 format using VB.net? Is there a function or something that can help with the...
1
by: phancey | last post by:
I am trying to invoke a web service method dynamically. I have created a generic function that takes a method name, string of parameters and calls the web method using System.Reflection: ...
19
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
3
by: Tim Osborne | last post by:
I want to know if a call to Convert.Int32 can handle a Culture specific string. I have the following code: string sText = "111,111,111"; int i; i = Convert.Int32(...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
3
by: James | last post by:
Has anyone written a utility to convert a C# form to C++.net? i.e. to convert "using System.Data" to "using namespace System::Data" etc
8
by: John A Grandy | last post by:
could someone please discuss the pros and cons of CType(MyDouble,Decimal) versus Convert.ToDecimal(MyDouble) .... and other such conversions ...
2
by: Allen Maki | last post by:
Hi Everybody, I am new to VC.NET and I need your help. I would like the array to print characters as '.'s (dots) instead of 0s as in (see below in front of //------>>>>>. I tried to...
14
by: Me | last post by:
Hi all I am getting a really bizzare error on when I convert a string into a datetime: The code is : DateTime dt1 = Convert.ToDateTime("10 Sep 2005"); Console.WriteLine(dt1.Year);
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.