You have a loop going through the individual parts of what is a string.
What if the string isn't 10 characters long? The loop will try and read past the end of the string, which doesn't exist, and there you get an overflow error. Your best bet is to use:
And use a switch instead of a huge list of If statements, much cleaner.Code:list<byte> binaryValue = new List<byte>(); foreach(byte x in Convert.ToByte(yourText)) { binaryValue.add(x); }