C# UnicodeEncoding GetByteCount(Char[])
Description
UnicodeEncoding GetByteCount(Char[])
When overridden
in a derived class, calculates the number of bytes produced by encoding all
the characters in the specified character array.
Syntax
UnicodeEncoding.GetByteCount(Char[])
has the following syntax.
public virtual int GetByteCount(
char[] chars
)
Parameters
UnicodeEncoding.GetByteCount(Char[])
has the following parameters.
chars
- The character array containing the characters to encode.
Returns
UnicodeEncoding.GetByteCount(Char[])
method returns The number of bytes produced by encoding all the characters in the specified
character array.
Example
using System;/*from ww w . j a va 2s.co m*/
using System.Text;
public class SamplesEncoding
{
public static void Main()
{
char[] chars = new char[] { 'z', 'a', '\u0306', '\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };
Encoding enc = Encoding.Unicode;
Console.WriteLine(enc.ToString());
int iBC = enc.GetByteCount(chars);
Console.WriteLine(" {0,-3}", iBC);
}
}
The code above generates the following result.