Class LongExtensions
Long 扩展方法
Inherited Members
Namespace: Lett.Extensions
Assembly: Lett.Extensions.dll
Syntax
public static class LongExtensions
Methods
| Improve this Doc View SourceIsEven(Int64)
是否偶数
Declaration
public static bool IsEven(this long this)
Parameters
Type | Name | Description |
---|---|---|
Int64 | this |
Returns
Type | Description |
---|---|
Boolean |
Examples
0L.IsEven(); // true
|
Improve this Doc
View Source
IsInRange(Int64, Int64, Int64)
是否在指定范围内
Declaration
public static bool IsInRange(this long this, long min, long max)
Parameters
Type | Name | Description |
---|---|---|
Int64 | this | |
Int64 | min | 最小值 |
Int64 | max | 最大值 |
Returns
Type | Description |
---|---|
Boolean |
Examples
(-1L).IsInRange(0, 10); // false
10L.IsInRange(0, 10); // true
|
Improve this Doc
View Source
IsOdd(Int64)
是否奇数
Declaration
public static bool IsOdd(this long this)
Parameters
Type | Name | Description |
---|---|---|
Int64 | this |
Returns
Type | Description |
---|---|
Boolean |
Examples
(-1L).IsOdd(); // true
|
Improve this Doc
View Source
Times(Int64, Action)
执行次数操作,次数基于 this
Declaration
public static void Times(this long this, Action action)
Parameters
Type | Name | Description |
---|---|---|
Int64 | this | |
Action | action | 执行的操作 |
Examples
var rs = 0;
10L.Times(() => rs += 1); // rs == 10
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | 执行次数 |
Times(Int64, Action<Int64>)
执行次数操作,次数基于 this
Declaration
public static void Times(this long this, Action<long> action)
Parameters
Type | Name | Description |
---|---|---|
Int64 | this | |
Action<Int64> | action | 执行的操作(参数是从0开始的 index) |
Examples
var rs2 = 0;
10L.Times(i => rs2 += i); // rs2 == 45
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | 执行次数 |