I'm new to programming and trying to create a simple console program that generates a random number between a range (in this case 1 and 15). I've looked on the internet for directions on using the Random class, but I am getting an error that I cannot understand. I wouldn't really post this otherwise (it seems basic) but I can't find anything on the internet that explains it very well.
using System;
public class Random
{
private int rNumber(int min, int max)
{
Random rGen = new Random();
return random.Next(1,15);
}
public static void Main();
{
Console.WriteLine("{0}", rNumber);
}
}
The compiler doesn't recognize "Next" as a method, which is why I tried using class Random -- it doesnt seem to recognize this Next function. The error is CS1061 - This error occurs when you try to call a method or access a class member that does not exist.
It was my understanding that the Random class is part of the System namespace, and I've called System. Is there another namespace I need to call in so that the "Next" function is recognized?

New Topic/Question
Reply
MultiQuote









|