Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果值大于或小于值,是否创建streamwriter文件?_C# - Fatal编程技术网

C# 如果值大于或小于值,是否创建streamwriter文件?

C# 如果值大于或小于值,是否创建streamwriter文件?,c#,C#,我想知道在比较两个值时是否可以编写一个新的streamwrite输出文件。我的一个值在LabelBox中,另一个在列表框中,由输入文件填充。假设它的目的是,只有当LabelBox值大于Listbox值时,此新值才应更改。请参阅以下代码: if (MaxRolls == 0) { Random getMax = new Random(); totalmoneyLabel.Text = ""; } else if (RollCount >= MaxRolls) { //

我想知道在比较两个值时是否可以编写一个新的streamwrite输出文件。我的一个值在LabelBox中,另一个在列表框中,由输入文件填充。假设它的目的是,只有当LabelBox值大于Listbox值时,此新值才应更改。请参阅以下代码:

if (MaxRolls == 0)
{
    Random getMax = new Random();
    totalmoneyLabel.Text = "";
}
else if (RollCount >= MaxRolls)
{
    //
    if (runningTotal >= highscore)
    {
        StreamWriter outputFile;
        outputFile = File.CreateText("HighScore.txt");
        outputFile.WriteLine("New Highscore!!");
        outputFile.WriteLine(totalmoneyLabel.Text);
        outputFile.Close();
    }
    //

    MaxRolls = 25;
    RollCount = 0; 
    runningTotal = 0;
    totalmoneyLabel.Text = "$0.00";
    Show();
    MessageBox.Show("You lost!");

    return;
}

一切皆有可能。你的问题是什么?什么不起作用?你的代码怎么了?问题是什么?程序将无法识别规则runningTotal>=highscore以确定是否需要重写输出文件…您的意思是条件未得到满足?您可以设置断点并检查runningTotal和highscore的值,然后查看这些值是否符合预期。您已告知LabelBox值何时更大,但使用了>=大于或等于