BrokeWebDeveloper
BrokeWebDeveloper

Reputation: 29

How to change integer value in C#?

I had made an integer named lifePoints then I set an If statement to CHANGE the integer's value from 100 to 90 how

int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
  {

    change integer value here. how?

  }

I searched google and it came out changing String to integer.

Upvotes: 0

Views: 3519

Answers (3)

CR0N0S.LXIII
CR0N0S.LXIII

Reputation: 359

If you want to set it to 90, then:

lifePoints = 90;

If you want to substract 10, then:

lifePoints -= 10; OR: lifePoints = lifePoints - 10;

Upvotes: 0

user12331852
user12331852

Reputation: 1

int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
  {

    lifePoints = 90; //CHANGE the integer's value from 100 to 90

  }

Upvotes: 0

Mario The Spoon
Mario The Spoon

Reputation: 4859

{
   lifePoints -= 10;
}

which corresponds to

{
   lifePoints = lifePoints - 10;
}

Upvotes: 2

Related Questions