[英]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.