문제

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
도움이 되었습니까?

해결책

Simply use

var byteArray = dataString.Select(x => (byte)x).ToArray();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top