Pregunta

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);
¿Fue útil?

Solución

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);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top