IntExtension.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Numerics;
  2. namespace Alchemy.Core.Extensions
  3. {
  4. public static class IntExtension
  5. {
  6. /// <summary>
  7. /// 整出取余
  8. /// </summary>
  9. /// <param name="timerCount"></param>
  10. /// <param name="timerInterval"></param>
  11. /// <returns></returns>
  12. public static bool RemainderSuccess(this int timerCount, int timerInterval)
  13. {
  14. return BigInteger.Remainder(new BigInteger(timerCount), new BigInteger(timerInterval)).Equals(0);
  15. }
  16. /// <summary>
  17. /// 判断是否合规端口
  18. /// </summary>
  19. /// <param name="param"></param>
  20. /// <returns></returns>
  21. public static bool IsPort(this int param)
  22. {
  23. if (param >= 1 && param <= 65535)
  24. {
  25. return true;
  26. }
  27. else
  28. {
  29. return false;
  30. }
  31. }
  32. /// <summary>
  33. /// 判断是否合规正整数和零
  34. /// </summary>
  35. /// <param name="param"></param>
  36. /// <returns></returns>
  37. public static bool IsIntNotNegative(this int param)
  38. {
  39. if (param >= 0)
  40. {
  41. return true;
  42. }
  43. else
  44. {
  45. return false;
  46. }
  47. }
  48. /// <summary>
  49. /// 判断是否合规月份数
  50. /// </summary>
  51. /// <param name="param"></param>
  52. /// <returns></returns>
  53. public static bool IsMonth(this int param)
  54. {
  55. if (param >= 1 && param <= 12)
  56. {
  57. return true;
  58. }
  59. else
  60. {
  61. return false;
  62. }
  63. }
  64. /// <summary>
  65. /// 判断是否合规正整数
  66. /// </summary>
  67. /// <param name="param"></param>
  68. /// <returns></returns>
  69. public static bool IsIntPositive(this int param)
  70. {
  71. if (param > 0)
  72. {
  73. return true;
  74. }
  75. else
  76. {
  77. return false;
  78. }
  79. }
  80. }
  81. }