Getters/Setters with C# Array

Hi all, in an attempt to condense code I am trying to keep an array of GetComponents for an array of gameobjects that are updated every time the array of gameobjects is updated with getters/setters. Here’s how it would work in my head:

private GameObject[] _SomeGO = new _SomeGO[3];
public SomeScript[] SomeGOScripts = new SomeGOScripts[3];

public GameObject[] SomeGO [int location] {
   get {return _SomeGO[location]};
   set {
      _SomeGO[location] = value;
      if (_SomeGO[location] == null) {
         SomeGOScripts[location] = null;
      }
      else {
         SomeGOScripts[location] = value.GetComponent<SomeScript>() as SomeScript;
      }
   }
}

However, this errors tremendously (I don’t think SomeGO is done correctly, but I don’t know how else to capture ‘location’). Any ideas on how to properly use getters/setters with a C# array?

I hope this helps:

public GameObject[] mSomeGO = new GameObject[3];

public GameObject[] SOME_GO
{
   get
   {
      return mSomeGO;
   }
   set
   {
      mSomeGO = value;
   }
}

There is no need to use something like ‘location’ in the getter/setter - just use it like

GameObject newGameObject = SOME_GO[2]

after filling the array (for example in the inspector) and it will work.