这个有简写吗:
在 C# 中?
bool b = (x > 0) && (x < 5);
类似这样:
bool b = 0 < x < 5;
在 C# 中?
bool b = (x > 0) && (x < 5);
类似这样:
bool b = 0 < x < 5;
bool b = 0 < x && x < 5
bool b = x*x < 5*x
0 < x & x < 5
由于 &
和 &&
在优先级表中相差很远,所以行为会有很大不同! - Bathsheba var counter = Random.Shared.Next(0,5);
if (counter is > 0 and < 5)
{
//Do logic
}
bool b = new[] { 1, 2, 3, 4 }.Contains(x);
bool b = (x > 212) && (x < 45872);
? - Lars KristensenEnumerable.Range(212+1, 45872-212-1)
的东西。 - w.b
bool b = 0 < x && x < 5;
- Matthew WatsonEnumerable.Range(1,4).Contains(x)
。 - Shaharyar