dear friends .
I want to create a instance of [R] class in [foreach] statement.
but all 10 responses are same same!
//
I want to create a instance of [R] class in [foreach] statement.
but all 10 responses are same same!
//
Code:
using System;
public partial class Class1: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string[] k = new string[10];
R cl;
foreach(string kx in k)
{
cl = new R();
Response.Write(cl.Ra() + "<br>");
}
}
}
public class R
{
private Random r;
public R()
{
r = new Random();
}
public int Ra()
{
return r.Next(100);
}
}
Comment