ではありません。これはおそらく非常に基本的なことですが、私はそれをGoogle検索して検索しましたが、最初のステートメントは結果を生成します。これは、私が他のステートメントを何とかしてしまったことを示しています。それは私を少し夢中にさせている。参考までに、これはフォームウィンドウで初めての経験です。C#if/else最初のステートメントは動作していますが、残りの部分は
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Wk2_Part1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int season;
int job;
season = Convert.ToInt32(textBox1.Text);
job = Convert.ToInt32(textBox2.Text);
if (season == 1)
if (job == 1)
label3.Text = "There is a 20% discount on the exterior job";
else
if (season == 2)
if (job == 1)
label3.Text = "There is a 20% discount on the exterior job";
else
if (season == 3)
if (job == 2)
label3.Text = "There is a 30% discount on the interior job";
else
label3.Text = "No discount, regular prices apply";
}
}
}
常に中かっこを使用してください。常に。 –
私はあなたのロジックを見て、switch文を使うのが最善の方法だと思います。 –