Hello everybody, I'm in need of a bit of help here. I got this C# snippet:
public static byte[] StringToByteArray(String hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
and I need to convert it to C++. This is how far I got:
public static byte[] StringToByteArray(String^ hex)
{
int NumberChars = hex->Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex->Substring(i, 2), 16);
return bytes;
}
I only changed . to -> and String to String^, so not much really. I'm working on a .NET project btw (CLR).