C# ASCIIEncoding GetString(Byte[], Int32, Int32)
Description
ASCIIEncoding GetString(Byte[], Int32, Int32)
Decodes
a range of bytes from a byte array into a string.
Syntax
ASCIIEncoding.GetString(Byte[], Int32, Int32)
has the following syntax.
public override string GetString(
byte[] bytes,/*from w ww.ja v a2 s.c o m*/
int byteIndex,
int byteCount
)
Parameters
ASCIIEncoding.GetString(Byte[], Int32, Int32)
has the following parameters.
bytes
- The byte array containing the sequence of bytes to decode.byteIndex
- The index of the first byte to decode.byteCount
- The number of bytes to decode.
Returns
ASCIIEncoding.GetString(Byte[], Int32, Int32)
method returns A String containing the results of decoding the specified sequence of bytes.
Example
using System;//w ww. j a v a 2 s. c om
using System.Text;
class ASCIIEncodingExample {
public static void Main() {
Byte[] bytes = new Byte[] {
65, 83, 67, 73, 73, 32, 69,
110, 99, 111, 100, 105, 110, 103,
32, 69, 120, 97, 109, 112, 108, 101
};
ASCIIEncoding ascii = new ASCIIEncoding();
String decoded = ascii.GetString(bytes);
Console.WriteLine(decoded);
}
}
The code above generates the following result.