Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace werk
{
public class Numbers
{
public ArrayList RandomNumbers(int max)
{
// Create an ArrayList object that will hold the numbers
ArrayList lstNumbers = new ArrayList();
// The Random class will be used to generate numbers
Random rndNumber = new Random();
// Generate a random number between 1 and the Max
int number = rndNumber.Next(0, max + 1);
// Add this first random number to the list
lstNumbers.Add(number);
// Set a count of numbers to 0 to start
int count = 0;
do
{
number = rndNumber.Next(0, max + 1);
// If the newly generated number in not yet in the list...
if (!lstNumbers.Contains(number))
{
// ... add it
lstNumbers.Add(number);
}
// Increase the count
count++;
}
while (count <= 10 * max); // Do that again
{
}
// Once the list is built, return it
return lstNumbers;
}
}
}
I have a question how do you read manually through an Arraylist i want read through this ArrayList by Button Click so i have to click the button 10 times and each time it picks a number it should display the picture of the random number it selected till Arraylist is either empty or fully read through ive tried a few things but it always gave the error : Error 1 Operator '==' cannot be applied to operands of type 'object' and 'int'
I am pretty new at coding and im trying to build a random 0-10 picture Generator that listens to the ArrayList depending on the number
Sorry if this is a very silly question any help is appreciated
- Tim