初始刷
This commit is contained in:
25
Infrastructure/Helper/RandomHelper.cs
Normal file
25
Infrastructure/Helper/RandomHelper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ZR.Infrastructure.Helper
|
||||
{
|
||||
public class RandomHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成n为验证码
|
||||
/// </summary>
|
||||
/// <param name="Length"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateNum(int Length)
|
||||
{
|
||||
char[] constant = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
||||
StringBuilder newRandom = new(constant.Length);
|
||||
Random rd = new();
|
||||
for (int i = 0; i < Length; i++)
|
||||
{
|
||||
newRandom.Append(constant[rd.Next(constant.Length - 1)]);
|
||||
}
|
||||
return newRandom.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user