C# ASCIIEncoding GetCharCount(Byte[], Int32, Int32)
Description
ASCIIEncoding GetCharCount(Byte[], Int32, Int32)
Calculates
the number of characters produced by decoding a sequence of bytes from the
specified byte array.
Syntax
ASCIIEncoding.GetCharCount(Byte[], Int32, Int32)
has the following syntax.
public override int GetCharCount(
byte[] bytes,/* w w w.java 2 s . c om*/
int index,
int count
)
Parameters
ASCIIEncoding.GetCharCount(Byte[], Int32, Int32)
has the following parameters.
bytes
- The byte array containing the sequence of bytes to decode.index
- The index of the first byte to decode.count
- The number of bytes to decode.
Returns
ASCIIEncoding.GetCharCount(Byte[], Int32, Int32)
method returns The number of characters produced by decoding the specified sequence of
bytes.
Example
using System;/*from w w w. j ava2s . com*/
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();
int charCount = ascii.GetCharCount(bytes, 6, 8);
Console.WriteLine(
"{0} characters needed to decode bytes.", charCount
);
}
}
The code above generates the following result.