//随机取数
private decimal GetRandomRate(decimal minValue,decimal maxValue)
{
int minValueInt = (int)(minValue* 100);
int maxValueInt = (int)(maxValue*100);
int resultInt = new Random().Next(minValueInt, maxValueInt);
decimal result = resultInt.ToDecimal() / 10000;
return CutDecimalWithN(result,2);
}
public static decimal CutDecimalWithN(decimal d, int n)
{
string strDecimal = d.ToString();
int index = strDecimal.IndexOf(".");
if (index == -1 || strDecimal.Length < index + n + 1)
{
strDecimal = string.Format("{0:F" + n + "}", d);
}
else
{
int length = index;
if (n != 0)
{
length = index + n + 1;
}
strDecimal = strDecimal.Substring(0, length);
}
return Decimal.Parse(strDecimal);
}