I'm new to C# (but not to coding), so if this is an easy fix please forgive me. I'm attempting to get the computer to generate a random number between 1 and 100,000. However, when mimicking the syntax I saw online, I receive the error "CS1061: 'Random' does not contain a definition for 'Next'and no extension method 'Next' accepting a first argument of type 'Random' could be found (are you missing a using directive or an assembly reference?"
When attempting to add "using System.Random();", the computer tells me the using directive is unneccessary, but when one gets rid of using it just creates more problems.
Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour {
// Use this for initialization
void Start () {
print("Welcome to Number Wizard!");
print("Pick a number in your head, but don't tell me!");
int max = 100000, min = 1;
print("Choose a number between "+min+" and "+max+".");
Random r = new Random();
int guess1 = r.Next();
}
// Update is called once per frame
void Update () {
}
}
Any input is greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire