How to pass objects through array?

So here is how the code looks like:

SomeClass someObject1;
GameObject gamObjX;

SomeClass[] myArray;

void Start ()
{
   myArray = new SomeClass[1];
   SomeMethod(ref gamObjX);
}

void SetElements ()
{
   myArray[0] = someObject1;
}

void SomeMethod (ref GameObject gamObj)
{
   myArray[0] = gamObj.GetComponent<SomeClass>();   // SomeClass script is attached to gamObj
}

void Update ()
{
   someObject1.DoSomethingWithGamObj()   // Error: Object reference not set to an instance of an object
   myArray[0].DoSomethingWithGamObj()   // Something is done
}

The only way I know how to solve this is using pointers. But Unity doesn’t allow pointers so…
Why does it happen? Are the elements in the array copies of actual variables? What happens when I call SetElements() method? I would like myArray[0] to be someObject1 (or ‘reference of’ should I say?) so if I do
myArray[0].someVar = 1; print(someObject1.someVar); would print 1 instead of null or some basic value.

A few things:

First, it’s not that Unity does’t allow pointers, its that C# doesn’t have pointers. [If you think you’re writing Javascript(UnityScript) you’re doing it way wrong]

Second, since gamObj is global, you don’t have to pass it by reference (or pass it in at all)

Now, to answer your question, I think you’re confused at how things work.

Just because you set myArray[0] = someObject1, doesn’t mean that someObject1 will always equal myArray[0].

You’re correct in thinking if you had used pointers, this might work. Anyway, to fix it:

After you do myArray[0] = gamObj.GetComponent(); // SomeClass script is attached to gamObj

just do someObject1 = myArray[0];// or gameObj.GetComponent();
to actually assign the component to someObject1

Now. After that’s all said, I’m not sure why you want two variables that reference the same component.