繁体   English   中英

如何更改 C# 中的 integer 值?

[英]How to change integer value in C#?

我制作了一个名为 lifePoints 的 integer 然后我设置了一个 If 语句将整数的值从 100 更改为 90 如何

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

    change integer value here. how?

  }

我搜索了谷歌,结果将字符串更改为 integer。

{
   lifePoints -= 10;
}

对应于

{
   lifePoints = lifePoints - 10;
}

如果要将其设置90 ,则:

lifePoints = 90;

如果要减去10 ,则:

lifePoints -= 10; 或: lifePoints = lifePoints - 10;

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

  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM