Reputation: 21
I have a error trying to do the following code
Random r = new Random();
r.Next(10, 100);
But I have a error:
Error 1 'ChaseRP_Admin_Control.AdminCP2.Random' does not contain a definition for 'Next' and no extension method 'Next' accepting a first argument of type 'ChaseRP_Admin_Control.AdminCP2.Random' could be found (are you missing a using directive or an assembly reference?)
C:\Users\Someone\documents\visual studio 2013\Projects\ChaseRP Admin Control\ChaseRP Admin Control\AdminCP2\Random.cs 24 39 ChaseRP Admin Control
Upvotes: 0
Views: 1430
Reputation:
From the error, you have a class in your namespace ChaseRP_Admin_Control.AdminCP2
that has the name Random
that doesn't have a Next()
method. You can change the name of the class.
Alternatively, You can put the System
namespace in front of the random to tell the compiler that you want the random from the system namespace not the one in your class.
System.Random r = new System.Random();
Upvotes: 3
Reputation: 22794
You have another class named Random
in your assembly. It doesn't have a Next()
method, like System.Random
. You need to either change the name or specify System.Random
explicitly, e.g.:
var r = new System.Random(); //look at the difference.
r.Next(10, 100);
Upvotes: 7
Reputation: 887195
ChaseRP_Admin_Control.AdminCP2.Random
You made your own Random
class, which doesn't have a Next()
method.
Either rename that class, or qualify the original one with its namespace (System.Random
)
Upvotes: 5