Pointers in C#, when are they used? : I am trying to implement a simple counter for a game. I want to be able to increment the fire, water and earth attributes using a method which takes a string and an int as arguments.

I am however not sure whether the following would work. I am not sure the ints within the elements array would point to the original attribute of the same name or if it would just make a copy of it in the array.

    class TypeCounter{
        int fire = 0;
        int water  = 0;
        int earth  = 0;
        string[] elementNames = {“fire”,”water”, “earth”};
        int[] elements = {fire, water, earth};
    
        public void AddTo(string element, int val){
            int keyIndex = Array.FindIndex(elementNames , element);
            elements[keyIndex] += val;
        }
    }

I want to be able to do the following:

    TypeCounter counter = new TypeCounter();
    
    public Run(){
        print counter.fire;
        counter.AddTo("fire", 1);
        print counter.fire;
    }

I would expect an output of `0` for the first print statement and `1` for the second, when I execute the Run() method.


