J'essaie de renvoyer un nombre aléatoire d'une méthode mais apparemment le type implicite n'est pas correct. Il dit: "Impossible de convertir implicitement le type 'Randomize.RandomNumber' à 'int'"Retour d'un type de nombre aléatoire Problème
RandomNumber.cs:
using System;
using System.Collections.Generic;
using System.Text;
namespace Randomizer
{
class RandomNumber
{
public int RandomInRange(int l, int u)
{
Random generator = new Random();
return generator.Next(l, u);
}
}
}
Program.cs:
using System;
using System.Collections.Generic;
using System.Text;
namespace Randomizer
{
class Program
{
static void Main(string[] args)
{
Console.Out.WriteLine("Please enter the minimum range for the random number\n");
int min = int.Parse(Console.In.ReadLine());
Console.Out.WriteLine("Please enter the maximum range for the random number\n");
int max = int.Parse(Console.In.ReadLine());
int RandomInt = new RandomNumber();
Console.Out.WriteLine("Your random number is: " + RandomInt.RandomInRange(min, max));
Console.In.ReadLine();
}
}
}
Je sais qu'il est à peu près un noob question, mais je suis habitué à C++. Merci pour l'aide à l'avance. =]
Ah, a un sens maintenant. Merci pour l'aide! – Stradigos