Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to realize a character conversion ASC in C#?
How to realize a character conversion ASC in C#?
Public static int Asc (string)

{

If (character. Length == 1)

{

System. Text.ascii encoding ascii encoding = new system. text . ascii encoding();

int intAsciiCode =(int)ascii encoding。 GetBytes(character)[0];

return(intAsciiCode);

}

other

{

Throws a new exception ("Invalid character." );

}

}

Call ASC () method to get ASC2 code, but the parameters passed must be letters. If it is a string, you should take each letter of the string one by one and put it in a permutation group, and then write a loop to call the ASC () method.