Mega Code Archive

 
Categories / C# / Development Class
 

Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array

using System; using System.Text; class DecoderExample {     public static void Main() {         Byte[] bytes = new Byte[] {5, 0, 10, 0, 105, 0, 99, 0, 111, 0, 100, 0, 101, 0};         Decoder uniDecoder = Encoding.Unicode.GetDecoder();         int charCount = uniDecoder.GetCharCount(bytes, 0, bytes.Length);         Console.WriteLine("{0} characters needed to decode bytes.", charCount);     } }