IEnumerable, changes to contained class not applied
Hey,
So I have this small code:
private class SlotAmmo
{
public int SpaceLeft { set; get; }
public EquipementSlot Slot { set; get; }
}
var slots = Equipements.Select(x => new SlotAmmo()
{
SpaceLeft = x.Info.MaxHold,
Slot = x
});
foreach (var s in slots) s.SpaceLeft = 0;
foreach (var s in slots) UnityEngine.Debug.Log($"Value: {s.SpaceLeft}");
private class SlotAmmo
{
public int SpaceLeft { set; get; }
public EquipementSlot Slot { set; get; }
}
var slots = Equipements.Select(x => new SlotAmmo()
{
SpaceLeft = x.Info.MaxHold,
Slot = x
});
foreach (var s in slots) s.SpaceLeft = 0;
foreach (var s in slots) UnityEngine.Debug.Log($"Value: {s.SpaceLeft}");
Where basically I'm just creating data, setting some values to 0 and then printing them
But all my prints show me non-zero values
Am I missing something obvious?