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" %>

    <!-- Code to call the fillArray method and display the array-->
    <% string msg;
       "<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]);
10 Years
Discussion Span
Last Post by majestic0110
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.