arrayShiftLib[lib]
does not contain anything for lib = 0,1 or 2 so the
.ToString()
method will fail.
When looping through any collection, do not use explicit ranges - rather check that you are within the collection - here are 3 different examples of how to do that.
for (int i = 0; i < arrayShiftLib.Length; i++)
for (int i = 0; i <= arrayShiftLib.GetUpperBound(0); i++)
foreach(string s in arrayShiftLib)
To check for nulls you could use
if (!String.IsNullOrEmpty(arrayShiftLib[i]))