Possible to edit multiple class properties at once for an existing instance?

When I instantiate a new class I’m able to open up brackets to change many properties at once ex:

public class Damage
{
  public int amount;
  public bool isCritical;
  public Element element;
}

//...

Damage outgoingDamage = new() { amount = 100, isCritical = true }

But I can’t figure out if it’s possible to do that same thing with an existing instance of a class. For example, my stats class calculates the base damage and if it’s going to be a critical or not, but then my MeleeAttack class considers the elemental properties of the weapon and may need to make more changes.

public Damage InitialDamageCalc()
    {
        return new Damage { amount = power, isCritical = true };
    }

//...

public Damage FinalDamageCalc()
  {
    Damage newDamage = stats.OutgoingDamage();
    newDamage.amount = 400;
    newDamage.Element = Element.fire;
    return newDamage;
  }

Is it possible to open up the brackets on stats.OutgoingDamage() so I can edit it as if I were instantiating a new instance of the class? Something like:

public Damage FinalDamageCalc()
    {
        Damage newDamage = stats.OutgoingDamage() {
          amount = 400,
          Element = Element.fire
        }
        return newDamage;
    }

//OR

public Damage FinalDamageCalc()
{
  return stats.OutgoingDamage() {
    amount = 400,
    Element = Element.fire
  }
}

No I don’t believe you can. What you’re referring to is an object initialiser, which is a bit of syntax-sugar on constructors that lets you set public fields.

In reality this:

Damage outgoingDamage = new() { amount = 100, isCritical = true }

Isn’t all that different to:

Damage outgoingDamage = new Damage();
outgoingDamage.amount = 100;
outgoingDamage.isCritical = true;

In the end there’s no need to worry about this as it makes no different.

As a side note it’s worth introducing constructors to your Damage class rather than using object initialisers.

Hey thanks @spiney199 I was just trying to clean my code up a bit and didn’t want to be redundant if I didn’t have to. I appreciate the clarification. Also, I had no idea what you meant about constructors so I’ve been reading up and it seems legit, I just need to figure out a way to make it flow where multiple scripts manipulate and hand off the same instance. You rock