C# How to deal with arrays inside a struct? : I'm looking for a way to replace some of my List objects with arrays in my project to boost performance. The reasoning is that the List I would replace do not change size often (sometimes only once), so it would make sense to swap them out with arrays. Also, I would like to prevent allocations on the heap as much as possible.

So my idea is to create a struct with two members "Count" and "Array". The struct would have some functions to add/remove/get/set/ect... elements in the array. The count would keep count of the elements that are usable in the array, and the array would only increase in size, never decrease.
Note that this is for a very particular case because I know the array size won't be very big.

So the main problem I have with that set up is when I use the assignment operator to copy the struct as the array is now shared between two variables instead of a having a new copy of the array.

The only thing I could come up with as an idea was trying to override the assignment operator so that it would create a new array on assignment... but obviously that does not work.

My ArrayStruct
```c#
    public struct ArrayStruct<T>
    {
        [SerializeField] private int m_Count;
        [SerializeField] private T[] m_Array;

        public int Count => m_Count;

        public void Initialize(int startSize)
        {
            m_Count = 0;
            m_Array = new T[startSize];
        }

        public T GetAt(int index)
        {
            return m_Array[index];
        }

        public void SetAt(int index, T newValue)
        {
            m_Array[index] = newValue;
        }

        public void Add(T newElement)
        {
            if (m_Array == null) {
                m_Array = new T[1];
            } else if (m_Array.Length == m_Count) {
                System.Array.Resize(ref m_Array, m_Count + 1);
            }

            m_Array[m_Count] = newElement;
            m_Count++;
        }

        public void Remove(T element)
        {
            for (int i = 0; i < m_Count; ++i) {
                if (!element.Equals(m_Array[i])) {
                    continue;
                }

                for (int j = index; j < m_Count - 1; ++j) {
                    m_Array[j] = m_Array[j + 1];
                }
                m_Count--;
                m_Array[m_Count] = default(T);
                break;
            }
        }

        //Trying to overload the = operating by creating a auto cast, this gives a compile error
        /*public static implicit operator ArrayStruct<T>(ArrayStruct<T> otherArray)
        {
            var newArray = new ArrayStruct<T>();
            newArray.m_Count = otherArray.Count;
            newArray.m_Array = new T[otherArray.Length];
            otherArray.m_Array.CopyTo(newArray.m_Array);
            return newArray;
        }*/
```


An example showcasing the problem
```c#
var a = new ArrayStruct<string>()
a.Add("hello");
var b = a;
print (b.GetAt(0)); //"hello"

a.SetAt(0, "new value for a");

print(b.GetAt(0));//"new value for a"  , changing a changed b because the array is the same in both, this is bad

a.Add("resizing array");
print (b.GetAt(1)); //"Out of range exception" ,  because the array was resized for a but not for b therefore the connection broke
```

So do any of you have an idea of how I could make a new copy the array when I assign the struct to another variable?
Of course, I know I could use a function to do something like so
b = new ArrayStruct(a);
But I want it to be implicit. Or if there was a way to prevent assignments that would also work for me.
var a = new ArrayStruct();//let this work
var b = a; //Prevent this from happening

If you have any other solutions for replacing Lists with arrays conveniently please let me know