What is wrong here?
string[] keysDictionary = new string[]{};
keysDictionary [0] = "test";
I get
System.IndexOutOfRangeException Array index is out of range.
You can't add anything to a 0 length array. You are essentially trying to set the value of the first element of an array with no elements. Use something like a list instead if you want to do this, arrays cannot be resized.
var keysDictionary = new List<string>();
keysDictionary.Add("test");
If you want an Array that dynamically changes size when you add values use a List instead.
ArrayList is a bit .net 1.1, more commonly you would use List<T>
new string[length]List<T>. It's an array-like structure that allows the addition of more elements.C#is a high level language it still has some very basic constructs, like fixed arrays which you are trying to use. Only use arrays (ie ´type[]´ syntax likeint[]) when you create a fixed collection you are going to be iterating over many times. In my opinion, for all other cases the performance gain is not worth the hassle of keeping track of the array size manually.