是否有一个&QUOT ...之间QUOT;在C#中的功能?

是否有一个&QUOT ...之间QUOT;在C#中的功能?

问题描述:

谷歌不明白之间是我找的函数的名称,并且没有返回相关的。

Google doesn't understand that "between" is the name of the function I'm looking for and returns nothing relevant.

例如:我要检查,如果5只在一个操作是0到10之间。

Ex: I want to check if 5 is between 0 and 10 in only one operation

没有,但你可以编写自己的:

No, but you can write your own:

public static bool Between(this int num, int lower, int upper, bool inclusive = false)
{
    return inclusive
        ? lower <= num && num <= upper
        : lower < num && num < upper;
}