using System.Text; string s = "Hello, world!"; int byteLength = Encoding.Unicode.GetByteCount(s);