需要有关C#的项目帮助 [英] need help with C# for project
问题描述
您好,我正在尝试在课堂上,在课堂上和在书本上进行编程的项目,但我们都拥有与此问题类似的内容,但是我找不到任何可以帮助我的东西.
Hello, I am trying to work on a programming project in class, in class and in the books we have stuff similar to this issue, but I could not find anything to help me.
错误是当我单击button1(选项1是变量名)时,它将同时运行2条if语句,我希望它在下一条if语句之前停止,然后当再次单击该按钮时,我想要下一条一个要运行.
The error is when I click button1(option1 is the variable name) it will run 2 if statements at the same time, I want it to stop before the next if statement then when the button is clicked again, I want the next one to run.
故事框也只是一个用于显示信息和文本的列表框. option2只是另一个按钮
Also storyBox is just a listbox used to display information and text. option2 is simply another button
private void option1_Click(object sender, EventArgs e)
{
if (option1.Text == ("Keyboard Warrior"))
{
storyBox.Items.Add("You have selected a Keyboard Warrior. Your health is set to 200, strength is set to 40, and armor is set to 20");
option1.Text = ("Explore");
option2.Text = ("Scavenge");
}
if (option1.Text == ("Explore"))
{
storyBox.Items.Add("You decide to explore, you mangage to find a house, the house looks dangerous would you like to enter?");
option1.Text = ("Yes");
option2.Text = ("No");
}
推荐答案
您好,我正在尝试在课堂上,在课堂上以及在书本上进行编程的项目问题,但是我找不到任何帮助.
Hello, I am trying to work on a programming project in class, in class and in the books we have stuff similar to this issue, but I could not find anything to help me.
错误是当我单击button1(选项1是变量名)时,它将同时运行2条if语句,我希望它在下一条if语句之前停止,然后再次单击该按钮时,我想要下一条一个要运行.
The error is when I click button1(option1 is the variable name) it will run 2 if statements at the same time, I want it to stop before the next if statement then when the button is clicked again, I want the next one to run.
故事框也只是一个用于显示信息和文本的列表框. option2只是另一个按钮
Also storyBox is just a listbox used to display information and text. option2 is simply another button
我还应该补充一点,这样做的目的是制作一个简单的基于文本的游戏
I should also add that the goal of this is to make a simple text based game
private void option1_Click(object sender, EventArgs e)
{
if (option1.Text == ("Keyboard Warrior"))
{
storyBox.Items.Add("You have selected a Keyboard Warrior. Your health is set to 200, strength is set to 40, and armor is set to 20");
option1.Text = ("Explore");
option2.Text = ("Scavenge");
}
if (option1.Text == ("Explore"))
{
storyBox.Items.Add("You decide to explore, you mangage to find a house, the house looks dangerous would you like to enter?");
option1.Text = ("Yes");
option2.Text = ("No");
}
这篇关于需要有关C#的项目帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!