Asc

Tamer_Ahmed

Well-known member
Joined
Dec 20, 2003
Messages
159
Location
Egypt
hi every one in VB.net if we want to get the ASC for any char for example A we use this fuction
Asc("A")
what about C# i didnt find this Function here does anyone here can help
 
oops its not working
sorry robby for that
i write the code like that
int myAsc = Convert.ToInt32(A);
MessageBox.Show(myAsc);
there error called
The name A does not exist in the class or namespace ConsoleApplication1.Class1
well i tried to put it like that

int myAsc = Convert.ToInt32("A");
here the error was
Input string was not in a correct format.
so do u have any advice for me
 
You need to enclose the A in single quote marks to pass it as
a Char type instead of as a String.

C#:
int myAsc = Convert.ToInt32(A);

In VB.NET, this is accomplished with a trailing c after the quote marks:
Code:
Dim myInt As Integer = Convert.ToInt32("A"c)
 
sorry this was stubid from me i must first Declare char
char c = A;
int myAsc = Convert.ToInt32(A);
MessageBox.show(myAsc.Tostring())
Thankss again robby and sorry for buzzing u :D
 
Back
Top