You cannot dynamically modify System.Array .
Fortunately, there is no reason for this. Use a different type of collection, such as List<T> . (Make sure you add a using declaration for the System.Collections.Generic namespace!)
Like an array, List<T> allows you to access items in a list by index, but also dynamically resize at runtime, which matches the requirements in your question. And, of course, since this is a general method, it has the additional advantage (compared to some of your other choices) that is strongly typed. Since you are working with string types, you should use List<string> .
EDIT: There is absolutely no need for this empty try / catch . Why catch an exception if you're just going to review it? Just let it bubble. In general, you should not catch exceptions, unless you can correct their immediate cause.
source share