 <p>In the loop, you are going from <code>0</code> to the length of <code>alarmDetailsSeparated</code>. This is fine, but you are then indexing <code>alarmDetailsSeparated</code> using <code>i+1</code> and <code>i+2</code>.</p> <p>This means that when the loop is at <code>alarmDetailsSeparated.Length-2</code> the program will index <code>alarmDetailsSeparated.Length-2+2 = alarmDetailsSeparated.Length</code> and throw an out of bounds error.</p>