Returns a sequence of bytes that specifies the encoding used.
using System; using System.Text; class GetPreambleExampleClass { static void Main() { Encoding unicode = Encoding.Unicode; byte[] preamble = unicode.GetPreamble(); if(preamble.Length >= 2) { if(preamble[0] == 0xFE && preamble[1] == 0xFF) { Console.WriteLine("encoding in big-endian order."); } else if(preamble[0] == 0xFF && preamble[1] == 0xFE) { Console.WriteLine("encoding in little-endian order."); } } } }