Random r = new Random( ); Random r = new Random(358493);Ans: The first noarg constructor call creates a Random object with a seed computed from the time of day clock on the computer. The second constructor call has an argument that is the seed for the random number generator. The second object will produce the same random numbers every time the application runs. The first object will produce different random numbers everytime the application runs.
Response.Write(r.Next( )); Response.Write(r.Next(65)); Response.Write(r.Next(1, 10));Ans: (1) min value=0, max value=2147483647; (2) min value=0, max value=64, (3) min value=1, max value=9.
<!- ASP.Net file with many mistakes. <%! Page %> <script language=C#> public void btnClickMe_Click(object sender, EventArgs e) { txtClicks.Text++; } <html xmlsn=http://www.w3.org/1999/xhtml> <head> <title>clickcounter2.aspx Example</title> <link rep=stylesheet class=css/txt href=examples.css> <body> </head> <h2>Find the Mistakes</h1> <form id=frm Main runat=server </form> <p>Random Value: <asp:Literal ID=litValue Value=0 style=text-align:right></p> </body>Ans: Here is the corrected version:
<!-- ASP.Net file with many mistakes. --> <%! Page Language=C# %> <script runat=server> public void btnClickMe_Click(object sender, EventArgs e) { int n = int.Parse(txtClicks.Text); n++; txtClicks.Text = n.ToString( ); } <html xmlns=http://www.w3.org/1999/xhtml>> <head> <title>clickcounter2.aspx Example</title> <link rep=stylesheet class=css/txt href=examples.css> </head> <body> <h2>Find the Mistakes</h2> <form id=frmMain runat=server> <p>Random Value: <asp:Literal ID=litValue Value=0 style=text-align:right></p> <p> <asp:Button ID=btnClickMe Text=Click Me OnClick=btnClickMe_Click /> </form> </body> </html>