Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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# 变量较大_C#_Variables_Comparison - Fatal编程技术网

C# 变量较大

C# 变量较大,c#,variables,comparison,C#,Variables,Comparison,有没有一种方法可以将一个较大的符号输入到一个变量中,这样我就可以在一个for..next循环中使用 我有以下资料: public int findUnused(bool useHighestFirst = true) { int plInd = 1; int stepSize = 1; int maxe = maxPlayerCount + 1; for (; plInd > maxe; plInd += stepSize) {

有没有一种方法可以将一个较大的符号输入到一个变量中,这样我就可以在一个for..next循环中使用

我有以下资料:

public int findUnused(bool useHighestFirst = true)
{        
    int plInd = 1;
    int stepSize = 1;
    int maxe = maxPlayerCount + 1;
    for (; plInd > maxe; plInd += stepSize)
    {
    // do something
    }
}
根据UseHighest,for循环首先必须向上或向下计数

如何将运算符()放入变量中?

您可以使用
Func
,它表示接受2个
int
参数并返回
bool
的函数:

Func<int, int, bool> condition = (x, y) => x > y;
// or
Func<int, int, bool> condition = (x, y) => x < y;
您可以使用
Func
,它表示接受2个
int
参数并返回
bool
的函数:

Func<int, int, bool> condition = (x, y) => x > y;
// or
Func<int, int, bool> condition = (x, y) => x < y;

不要忘记更改倒计时版本的
stepSize
符号。@dlatikay我想OP已经处理好了。他可能事先将其设置为负值。这不是问题,所以我没有把它包括在我的答案中。如果他们不知道怎么做,OP会问这个问题。我想OP只是对如何做条件部分感到困惑。工作得很好。谢谢,不要忘记为倒计时版本更改
步长的符号。@dlatikay我想OP已经处理好了。他可能事先将其设置为负值。这不是问题,所以我没有把它包括在我的答案中。如果他们不知道怎么做,OP会问这个问题。我想OP只是对如何做条件部分感到困惑。工作得很好。谢谢,但逻辑是混乱的。首先在循环的末尾添加一些代码,如果达到maxe或zero,则会反转步长。然后在循环条件表达式中,将一些逻辑放在循环中,以一种方式对正步长进行比较,如果是负步长,则以相反的方式进行比较,可能重复“是”,但逻辑混乱。首先在循环的末尾添加一些代码,如果达到maxe或zero,则会反转步长。然后,在循环条件表达式中,将一些逻辑放在中,以一种方式对正步长进行比较,如果是负步长,则以相反的方式进行比较