1> declare one counter varibale globally
2> then when you add values to the array increament the counter varibale
3> and at last after all the adding to the array is finish then outside of any for loop add this line
Array.Resize(ref strArray , counter);