Pregunta

I have to convert string to ascii byte array.

How can I replace the following command when I don't have access to ASCII in system.text? This library is limited in mvvmcross framework.

byte[] byteArray = Encoding.ASCII.GetBytes(dataString);

I have access only to:

Encoding.UTF8
Encoding.Unicode
Encoding.BigEndianUnicode

not to

Encoding.ASCII
¿Fue útil?

Solución

Simply use

var byteArray = dataString.Select(x => (byte)x).ToArray();
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top