后台数据表建立
This commit is contained in:
28
20220330_Vote/Ewide.Core/Util/RandomHelper.cs
Normal file
28
20220330_Vote/Ewide.Core/Util/RandomHelper.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Util
|
||||
{
|
||||
public class RandomHelper
|
||||
{
|
||||
private const string BASECODE = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789";
|
||||
/// <summary>
|
||||
///生成指定位数的随机码(数字)
|
||||
/// </summary>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateRandomCode(int length)
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
var r = new Random(Guid.NewGuid().GetHashCode());
|
||||
result.Append(BASECODE[r.Next(BASECODE.Length)]);
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user