|
-
Apr 27th, 2007, 12:05 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Ascii Function
Hi....
I'm confuse about the ascii function in C#, coz I'm a newbie here.
I'm using VB6 before. I don't know what syntax should I use in C#.
At VB6, I use as below :
Code:
Dim AA as string
Dim BB
Dim i
AA = "Hello"
for i = 1 to len(AA)
BB = mid(trim(AA), i, 1)
msgbox Asc(BB)
next i
how should I write those code in C# ?
Thanks...
** Willy **
Last edited by Wen Lie; May 4th, 2007 at 12:07 AM.
Reason: problem solved
Regards,
[-w-]
-
Apr 27th, 2007, 12:19 AM
#2
Re: Ascii Function
You could write fairly similar code but you wouldn't want to. You get the length of a string from its Length property, you get part of a string using its Substring method, and you get the numerical value of a character using the Comnvert.ToInt32 method. That can all be written much more succinctly in C# though:
vb Code:
string myString = "Hello";
foreach (char ch in myString)
{
MessageBox.Show(Convert.ToInt32(ch).ToString());
}
Note that the VB.NET code would be similar, although you could also write VB.NET code that more closely resembled the original.
-
Apr 27th, 2007, 03:54 AM
#3
Thread Starter
Fanatic Member
Re: Ascii Function
thanks...
i've tried and work...
many thanks.
** willy **
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|