【发布时间】:2014-10-11 10:14:50
【问题描述】:
我需要使用 ASP.NET 将一些“经典 ASP 3.0”代码转换为 C#:
Randomize()
intUP = 9
intLow = 1
intRange = intUp - intLow
intRandom = CInt ((intRange * Rnd()) + intLow)
Response.Write(intRandom & "<br /><br />")
for i = 1 to (num) + intRandom
Response.Write(intRandom & "<br />")
next
我已经尝试过这段代码:
int count;
Random rnd;
protected void Page_Load(object sender, EventArgs e)
{
rnd = new Random();
count = GetRandomInt(1, 9);
for (int i = 0; i < count; i++)
{
Response.Write(count.ToString());
}
}
protected int GetRandomInt(int min, int max)
{
return rnd.Next(min, max);
}
但在 Classic ASP 3.0 中,最大输出为 9,但在 C# 和 ASP.NET 中,要高得多。
我错过了什么?
这段代码有什么问题?
提前谢谢你。
【问题讨论】:
标签: c# asp.net asp-classic