Dicom.IO.Endian.SwapBytes2 C# (CSharp) Method

SwapBytes2() public static method

public static SwapBytes2 ( byte bytes ) : void
bytes byte
return void
        public static void SwapBytes2(byte[] bytes)
        {
            unchecked {
                byte b;
                int l = bytes.Length - (bytes.Length % 2);
                for (int i = 0; i < l; i += 2) {
                    b = bytes[i + 1];
                    bytes[i + 1] = bytes[i];
                    bytes[i] = b;
                }
            }
        }

Usage Example

Example #1
0
 public void Swap2()
 {
     Endian.SwapBytes2(ToBytes());
 }