我的代码中出现以下错误,我不确定为什么:
警告 -'SummaryForm.m_difficulty' is never assigned to, and will always have its default value 0
代码
public partial class SummaryForm : Form
{
// Declares variables with the values pulled from the 'MainForm'
int iCorrectACount = MainForm.iCorrectACount;
int iCurrentQIndex = MainForm.iCurrentQIndex;
private Difficulty m_difficulty;
public SummaryForm()
{
InitializeComponent();
double modifier = 1.0;
if (m_difficulty == Difficulty.Easy) { modifier = 1.0; }
if (m_difficulty == Difficulty.Medium) { modifier = 1.5; }
if (m_difficulty == Difficulty.Hard) { modifier = 2; }
// Sets the labels using integer values
lblCorrectNum.Text = iCorrectACount.ToString();
lblWrongNum.Text = (iCurrentQIndex - iCorrectACount).ToString();
lblScoreTotal.Text = (iCorrectACount * modifier).ToString();
}
也许这与为什么lblScoreTotal.Text
不会更改为 value * 修饰符但会更改为另一种形式有关?
我在这里问这个问题的原因是有人建议我禁用警告消息,但我认为这不是合适的解决方案?
谢谢。