Advertisement
pszczyg

Untitled

Apr 1st, 2017
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. public static Guid FlipEndian(this Guid guid)
  2. {
  3.     var newBytes = new byte[16];
  4.     var oldBytes = guid.ToByteArray();           
  5.     for (var i = 8; i < 16; i++)
  6.         newBytes[i] = oldBytes[i];
  7.     newBytes[3] = oldBytes[0];
  8.     newBytes[2] = oldBytes[1];
  9.     newBytes[1] = oldBytes[2];
  10.     newBytes[0] = oldBytes[3];
  11.     newBytes[5] = oldBytes[4];
  12.     newBytes[4] = oldBytes[5];
  13.     newBytes[6] = oldBytes[7];
  14.     newBytes[7] = oldBytes[6];
  15.  
  16.     return new Guid(newBytes);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement