문제

In java, you can build a String from a sub-range of a byte[]. How can we perform a similar operation in C#?

Example java code:

byte[] buffer = ...
int offset    = ...
int length    = ...

String str = new String(buffer, offset, length);
도움이 되었습니까?

해결책

System.Text.Encoding.UTF8.GetString() method has an overload to do this.

byte[] buffer = ... 
int offset    = ...
int length    = ...

String str = System.Text.Encoding.UTF8.GetString(buffer, offset, length);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top