The dock.ForbiddenZones is of type string [] array and by default is not instantiated (so an element at a given index cannot be accessed because such an index does not exist in the first place). You have to instantiate it yourself. This can be done by the following code line: