473,387 Members | 1,536 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.

Get Ascii value of a character

Hi
I am using the following

Text = Convert.ToChar(67).ToString() & this will give a "C"

How can I do the opposite that is pass a "C" and an integer value is returned.

Thanks

Ivan Sammut

Nov 16 '05 #1
1 46574
Sammut <sa*****@hotmail.com> wrote:
I am using the following

Text = Convert.ToChar(67).ToString() & this will give a "C"

How can I do the opposite that is pass a "C" and an integer value is returned.


The above is pretty unnecessary, to be honest. You can get away without
Convert - just cast:

char c = (char)67;
string s = c.toString();

and the other way round:

string s = "C";
char c = s[0]; // First character in s
int i = c; // i=67 now

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

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

Similar topics

4
by: Steve Horsley | last post by:
How can I get the ASCII value of a character, e.g. I have: str = "A B" for index in range(0, len(str)): value = WHAT_GOES_HERE?(str) print value and I hope to get: 65
6
by: Haas | last post by:
Hello folks, I just started a C++ course. An exercise is to give the ASCII value of a character read from keyboard. I place the input from the keyboard in a char-variable. How can i get the...
2
by: questions | last post by:
How do I convert a number to its ascii value in c#? What is the equivalent of VB's chr() function in c#? thanks in advance
1
by: James Dean | last post by:
i want to be able to get the correct ascii value from a byte without having to use the Convert.ToChar function as a char takes up two bytes of space and it is affecting the performance of my...
2
by: Microsoft News | last post by:
Hoe to calculate ASCII value of a character
7
by: datttanand | last post by:
can anybody send me the code snippet to find the ascii value of character?
1
by: sajit | last post by:
hi folks, I am developing a module in asp.net with c# as code behind. The module is used to encrypte the password. The problem is how to find the ascii value of particular character. Any help...
6
by: ssetz | last post by:
Hello, For work, I need to write a password filter. The problem is that my C+ + experience is only some practice in school, 10 years ago. I now develop in C# which is completely different to me....
3
by: krishnaneeraja | last post by:
Hi, im developing one web application using asp.net,c#.net.In that i want to find ASCII value of first character in a string.plz help me. thanks.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.