- int len = address.Length;
- if (((len - 2) / 3) != ndashes)
- throw new FormatException ("Invalid physical address.");
-
- byte [] data = new byte [ndashes + 1];
- int idx = 0;
- for (int i = 0; i < len; i++) {
- byte b = (byte) (GetValue (address [i++]) << 8);
- b += GetValue (address [i++]);
- if (address [i] != '-')
- throw new FormatException ("Invalid physical address.");
- data [idx++] = b;
+ if (addrSplit.Length == numberOfBytes) {
+ foreach (string str in addrSplit)
+ if (str.Length > 2)
+ throw new FormatException("An invalid physical address was specified.");
+ else if (str.Length < 2)
+ throw new IndexOutOfRangeException("An invalid physical address was specified.");
+ }
+ else
+ throw new FormatException("An invalid physical address was specified.");
+
+ byte[] data = new byte[numberOfBytes];
+ for (int i = 0; i < numberOfBytes; i++) {
+ byte b = (byte)(GetValue(addrSplit[i][0]) << 4);
+ b += GetValue(addrSplit[i][1]);
+ data[i] = b;