Exemple #1
0
        public static void Test()
        {
            var creatures = new BadCreature[100];

            foreach (var c in creatures)
            {
                // В памяти, данные класса BadCreature хранятся в периодическом виде
                // byte int int byte int int... и при работе с массивом таких объектов
                // комп работает неэффективно, прыгая через ненужные параметры
                c.X++; // not memory-efficient
            }

            var creatures2 = new Creatures(100);

            foreach (var c in creatures2)
            {
                c.X++;
            }
        }
Exemple #2
0
 public Creature(Creatures creatures, int index)
 {
     this.creatures = creatures;
     this.index     = index;
 }