Skip to content

Instantly share code, notes, and snippets.

@jonsagara
Created July 3, 2013 15:55
Show Gist options
  • Save jonsagara/5919700 to your computer and use it in GitHub Desktop.
Save jonsagara/5919700 to your computer and use it in GitHub Desktop.
Convert a SQL Server version to a byte array in C#
var hexNum = "0x000000000000E295";
long result;
long.TryParse(
hexNum.Substring(2),
System.Globalization.NumberStyles.HexNumber | System.Globalization.NumberStyles.AllowHexSpecifier,
System.Globalization.CultureInfo.CurrentCulture,
out result
);
//result.Dump();
var resultBytes = BitConverter.GetBytes(result);
resultBytes.Reverse().Dump();
resultBytes[0].Dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment