|
|
|
@ -104,21 +104,9 @@ namespace ICSharpCode.ILSpy.AddIn
@@ -104,21 +104,9 @@ namespace ICSharpCode.ILSpy.AddIn
|
|
|
|
|
{ |
|
|
|
|
var result = new byte[hex.Length / 2]; |
|
|
|
|
for (int i = 0; i < hex.Length / 2; i++) { |
|
|
|
|
result[i] = (byte)(ParseNibble(hex[i * 2]) * 16 |
|
|
|
|
+ ParseNibble(hex[i * 2 + 1])); |
|
|
|
|
result[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int ParseNibble(char c) |
|
|
|
|
{ |
|
|
|
|
if (c >= '0' && c <= '9') |
|
|
|
|
return c - '0'; |
|
|
|
|
if (c >= 'A' && c <= 'F') |
|
|
|
|
return c - 'A' + 10; |
|
|
|
|
if (c >= 'a' && c <= 'f') |
|
|
|
|
return c - 'a' + 10; |
|
|
|
|
throw new ArgumentException("Invalid hex digit: " + c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|