OVH Cloud OVH Cloud

Ascii

2 réponses
Avatar
BR
Bonjour,

Une question simple, mais je ne trouve pas ...
Comment obtenir le caractère correspondant au code ascii qu'on passerait en
paramètre (ex : chr(65) fornirait A)
Merci
Benoît

2 réponses

Avatar
Arnaud CLERET
Bonjour,

Cet exemple retourne bien 'A' à partir du code '65' :
string result = Encoding.ASCII.GetString(new byte[] { 65 });

--
arno - http://www.dotnetguru2.org/acleret/


"BR" a écrit :

Bonjour,

Une question simple, mais je ne trouve pas ...
Comment obtenir le caractère correspondant au code ascii qu'on passerait en
paramètre (ex : chr(65) fornirait A)
Merci
Benoît


Avatar
S. Lorétan
char -> int
char c = 'A';
int n = (int)c;

Et l'inverse
int n = 65;
char c = (char)n;

"BR" a écrit dans le message de news:

Bonjour,

Une question simple, mais je ne trouve pas ...
Comment obtenir le caractère correspondant au code ascii qu'on passerait
en
paramètre (ex : chr(65) fornirait A)
Merci
Benoît