•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 401,589 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,653 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 393 | Replies: 1
![]() |
•
•
Join Date: Oct 2007
Posts: 13
Reputation:
Rep Power: 1
Solved Threads: 0
I am very new to ASP.net and never used this feature before. I am trying to generate a code that will generate random numbers. The numbers must be in the range from 10-100. This is what I have generated. However, I am still running into some difficulty.
................................................
// test.aspx.cs
// The code behind file for test.aspx
// Includes a function to build an array of ten pseudorandom
// numbers
using System;
using System.Web;
using System.Web.UI;
public class test : Page
{
// Build a pseudorandom number method
System.Random RandNum = new System.Random();
int MyRandomNumber = RandNum.Next(10, 100);
protected int[] myArray = new int[10];
// A method to fill the array with pseudorandom numbers
public void fillArray()
{
for (int index = 0; index < 10; index++)
// Generate a pseudorandom number in the range of 10 to 100
myArray[index] = randomGen.Next(10, 100);
}
}
................................................
<!-- test.aspx
A simple example of an ASP.NET document with a code-behind file
It has the same functionality as test.aspx
-->
<%@ Page Language="C#" Inherits="test" Src="test.aspx.cs" %>
<html>
<head>
<title>test</title>
</head>
<body>
<!-- Code to call the fillArray method and display the array-->
<% string msg;
fillArray();
Response.Write(
"<br /> <b>The array’s contents are: </b><br /><br />");
for (int index = 0; index < 10; index++)
{
msg = string.Format("The element at {0} is: {1} <br />",
index, myArray[index]);
Response.Write(msg);
}
%>
</body>
</html>
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation api blogger blogging blogs code code injection coding combo competition compilers dani daniweb data developer development dreamweaver dropdownlist epilepsy gaming.coding gdata google gpl griefers hackers html javascript key linux microsoft module net news openbsd product programming reuse rss search serial source streaming tags video vista web wysiwyg xml
- Previous Thread: Find & Replace Dialog
- Next Thread: error while hosting



Linear Mode