- There is something better than Convert for the 2 operations in the following code?
- I'd like to know if this solution (sprintf) is better (or worst) than one with the use of Substring
- I'd like to know if using a list here would be better
- The previous 2 questions change within the size of the string? (a short one (less than 20 chars) or a long one)
Assume the input is always correct (no odd lenght).
let hexToAscii (hex:string) =
let chars = Array.zeroCreate<char> (hex.Length/2)
for i in 1..2..hex.Length-1 do
chars.[i/2] <- Convert.ToChar(Convert.ToByte(sprintf "%c%c" hex.[i-1] hex.[i] , 16))
String(chars)
Is a question like this better suited for https://codereview.stackexchange.com ?