The unit of objects does not change when objects change C#



  • There is a structure that stores a number of objects and a range of these objects (Going a mass so that all values can be quickly removed)

     public struct Stats : ICloneable
        {
            public AStat hp;
            public AStat stamina;
            public AStat meleeAtk;
            public AStat meleeDef;
            //массив полей
            public AStat[] AllStats;
            //конструктор
            public BrotherStats(string lol)
            {
                hp = new hpC();
                stamina = new staminaC();
                meleeAtk = new meleeAtkC();
                meleeDef = new meleeDefC();;
                AllStats = new IStat[8] { hp, stamina, meleeAtk, meleeDef };
            }
        }
    

    The problem is, when it became necessary for me to consider the meanings not from the fields themselves but from the mass, it turns out that all the meanings of default, not those that keep the fields. These fields are specimen of the class, and as far as I know the classes are reference types, so when their copies are altered, their meanings in the body must change. Or am I wrong?
    And also, can I help with the IEnumetator/IEnumerable interface instead of a field mass?



  • You misled class. hpCstaminaCmeleeAtkCmeleeDefC from class AStat



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2