Mega Code Archive

 
Categories / C# / Internationalization
 

Calculates the number of bytes produced by encoding

using System; using System.Text; class ASCIIEncodingExample {     public static void Main() {         Char[] chars = new Char[] {             '\u0023', // #             '\u03a3'  // Sigma         };         ASCIIEncoding ascii = new ASCIIEncoding();         int byteCount = ascii.GetByteCount(chars, 1, 2);         Console.WriteLine(byteCount);     } }