473,497 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Asc equivalent?

Hello folks,

Does anyone know the equivalent VB Asc function for C#?

Or ways around it?
Thanks in advance
Pete
Nov 15 '05 #1
6 5239
Peter Z <pe*********@primus.com.au> wrote:
Does anyone know the equivalent VB Asc function for C#?

Or ways around it?


Could you say *exactly* what you want to do? Note that the value of any
char is its unicode value - and if the character is an ASCII character,
that will be exactly the ASCII value.

If you want to know the value of any character in the system's default
code page, you should look at using Encoding.Default.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2
Marvellous effort that!
"NULL" <Thomas-dot-Delrue-at-Tiscali-dot-Be> wrote in message
news:s1********************************@4ax.com...
On Tue, 2 Sep 2003 18:48:39 +0800, "Peter Z"
<pe*********@primus.com.au> wrote:
Hello folks,

Does anyone know the equivalent VB Asc function for C#?

Or ways around it?


try this

int nASCII = (int)'A'; //should give 65 or 91 or something like
//that...?
int nASCII2 = (int)myCharVariable;
int nASCII3 = (int)myString[1]; //second char in string

Nov 15 '05 #3
NULL <Thomas-dot-Delrue-at-Tiscali-dot-Be> <NULL <Thomas-dot-Delrue-at-
Tiscali-dot-Be>> wrote:
Marvellous effort that!


What do you mean?

It is simple as 1-2-4 (sorry, 1-2-3 :) )
just like in C, C++ (etc.) a char is a datatype of 1 byte


Um, no. char is a datatype of *2* bytes...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #4
On Tue, 2 Sep 2003 13:55:47 +0100, Jon Skeet <sk***@pobox.com> wrote:
NULL <Thomas-dot-Delrue-at-Tiscali-dot-Be> <NULL <Thomas-dot-Delrue-at-
Tiscali-dot-Be>> wrote:
>Marvellous effort that!


What do you mean?

It is simple as 1-2-4 (sorry, 1-2-3 :) )
just like in C, C++ (etc.) a char is a datatype of 1 byte


Um, no. char is a datatype of *2* bytes...


Unicode? Ah... didn't know that...
anyway, the conversion still works :)

Nov 15 '05 #5
On Tue, 2 Sep 2003 13:55:47 +0100, Jon Skeet <sk***@pobox.com> wrote:
NULL <Thomas-dot-Delrue-at-Tiscali-dot-Be> <NULL <Thomas-dot-Delrue-at-
Tiscali-dot-Be>> wrote:
>Marvellous effort that!


What do you mean?

It is simple as 1-2-4 (sorry, 1-2-3 :) )
just like in C, C++ (etc.) a char is a datatype of 1 byte


Um, no. char is a datatype of *2* bytes...


Jon Skeet said:
Note that the value of any char is its unicode value


Yeah, should have known that one :)

--
NULL
Nov 15 '05 #6
On Wed, 3 Sep 2003 07:11:21 +0800, "Pete Z" <pe***@infovision.com.aj>
wrote:
It's a way of saying thankyou!
:D
np (sorry, a bit too much hours wihtout sleep I guess. :S sorry)


"NULL" <Thomas-dot-Delrue-at-Tiscali-dot-Be> wrote in message
news:nl********************************@4ax.com.. .
On Tue, 2 Sep 2003 19:22:16 +0800, "Peter Z"
<pe*********@primus.com.au> wrote:
>Marvellous effort that!


What do you mean?

It is simple as 1-2-4 (sorry, 1-2-3 :) )
just like in C, C++ (etc.) a char is a datatype of 1 byte, that can be
converted to any other (native) datatype that is larger (int, short,
long, byte, etc...) by just casting it...
You can also try this:

int nASCII = Convert.ToInt32 ('A');
long lASCII = Convert.ToInt64 ('B');
short sASCII = Convert.ToInt16 ('C'); //short==16 bits? (I though so)

--
NULL
>"NULL" <Thomas-dot-Delrue-at-Tiscali-dot-Be> wrote in message
>news:s1********************************@4ax.com.. .
>> On Tue, 2 Sep 2003 18:48:39 +0800, "Peter Z"
>> <pe*********@primus.com.au> wrote:
>>
>> >Hello folks,
>> >
>> >Does anyone know the equivalent VB Asc function for C#?
>> >
>> >Or ways around it?
>>
>> try this
>>
>> int nASCII = (int)'A'; //should give 65 or 91 or something like
>> //that...?
>> int nASCII2 = (int)myCharVariable;
>> int nASCII3 = (int)myString[1]; //second char in string


Nov 15 '05 #7

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

Similar topics

14
7211
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
3265
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
3
2269
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
1
3766
by: Vannela | last post by:
Is there any equivalent control in .NET for the Power builder DataWindow control? I am explaining the Datawindow architecture to some extent. Power Builder DataWindow Control has got different...
6
5139
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The...
3
3125
by: Marty | last post by:
Hi, What is the VB.NET equivalent of the VB6 ADODB.Connector and ADODB.Recordset? Thanks Marty
7
3705
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
10
7300
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
4027
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
14
2518
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
0
7120
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
6991
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
7160
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
7196
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...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.