gpt4 book ai didi

c# - 我在 if block 中分配了多个在外部引用的变量,但我又添加了两个它们似乎不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 16:24:04 26 4
gpt4 key购买 nike

我在 if 中分配了 classability1 和 2,{12} 和 {13} 最终未分配。我不确定我在这里做错了什么,但这可能很简单。

else if (Class == "Cleric" || Class == "cleric")
{
Class = "Cleric";
AD = 5;
AP = 25;
AS = 10;
mana = 250;
classability1 = "Heal";
classability2 = "Smite";
}

Console.Clear();
Console.WriteLine(@"Name = {0}
Race = {1}
Class = {2}
----------------------
Attack Damage = {3}
Ability power = {4}
Attack Speed = {5}
Armor = {6}
Magic Resist = {7}
Health = {8}
Mana = {9}
----------------------
Racial Bonuses
{10}
{11}
-----------------------
Class Abilities
{12}
{13}
Push enter to continue...", name, race, Class, AD, AP, AS, armor, magres, health, mana, racialbonus1, racialbonus2, classability1, classability2);
Console.ReadKey();

最佳答案

如前一位发帖人所述,请发布整个代码块。听起来确实很像

else if (Class == "Cleric" || Class == "cleric")
{
Class = "Cleric";
AD = 5;
AP = 25;
AS = 10;
mana = 250;
classability1 = "Heal";
classability2 = "Smite";
}

没有被执行。另一种可能性是,在 if 语句和 Console.Write 行之间可能存在其他代码,这些代码未在您的帖子中显示并且正在重新初始化/使字符串无效?

关于c# - 我在 if block 中分配了多个在外部引用的变量,但我又添加了两个它们似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13079290/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com