12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System.Numerics;
- namespace Alchemy.Core.Extensions
- {
- public static class IntExtension
- {
- /// <summary>
- /// 整出取余
- /// </summary>
- /// <param name="timerCount"></param>
- /// <param name="timerInterval"></param>
- /// <returns></returns>
- public static bool RemainderSuccess(this int timerCount, int timerInterval)
- {
- return BigInteger.Remainder(new BigInteger(timerCount), new BigInteger(timerInterval)).Equals(0);
- }
- /// <summary>
- /// 判断是否合规端口
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- public static bool IsPort(this int param)
- {
- if (param >= 1 && param <= 65535)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 判断是否合规正整数和零
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- public static bool IsIntNotNegative(this int param)
- {
- if (param >= 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 判断是否合规月份数
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- public static bool IsMonth(this int param)
- {
- if (param >= 1 && param <= 12)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 判断是否合规正整数
- /// </summary>
- /// <param name="param"></param>
- /// <returns></returns>
- public static bool IsIntPositive(this int param)
- {
- if (param > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
|