C# ASCIIEncoding GetMaxCharCount
Description
ASCIIEncoding GetMaxCharCount
Calculates the maximum
number of characters produced by decoding the specified number of bytes.
Syntax
ASCIIEncoding.GetMaxCharCount
has the following syntax.
public override int GetMaxCharCount(
int byteCount
)
Parameters
ASCIIEncoding.GetMaxCharCount
has the following parameters.
byteCount
- The number of bytes to decode.
Returns
ASCIIEncoding.GetMaxCharCount
method returns The maximum number of characters produced by decoding the specified number
of bytes.
Example
using System;//w ww . jav a 2 s. c o m
using System.Text;
class ASCIIEncodingExample {
public static void Main() {
ASCIIEncoding ascii = new ASCIIEncoding();
int byteCount = 8;
int maxCharCount = ascii.GetMaxCharCount(byteCount);
Console.WriteLine(
"Maximum of {0} characters needed to decode {1} bytes.",
maxCharCount,
byteCount
);
}
}
The code above generates the following result.