获取随机数
举例:0-9
Random random = new Random();
int j = random.Next(0, 9);
0、1两个值被取值的概率相等
int a = Math.Abs(Guid.NewGuid().GetHashCode()) % 2;
if (a == 0)
{}
else if(a==1)
{}
/// <summary>
/// 获取等概率的小于最大数的非负随机数
/// </summary>
/// <param name="n">最大数</param>
/// <returns></returns>
public static int Estimate(int n)
{
return Math.Abs(Guid.NewGuid().GetHashCode()) % n;
}