Sorry if this question is terrible, i am very new to c#, and i'm trying to write a console app, that does dicerolls with multiple types of dice, and after having done that, asks the user to confirm a new roll, or quit. so far i have this:
namespace diceroll
{
class Program
{
static void Main(string[] args)
{
Random rand = new Random();
int d4 = rand.Next(1, 5);
int d6 = rand.Next(1, 7);
int d8 = rand.Next(1, 9);
int d10 = rand.Next(1, 11);
int d12 = rand.Next(1, 13);
int d20 = rand.Next(1, 21);
string rolltype;
Console.WriteLine("what do you want to roll?");
rolltype = (Console.ReadLine());
Console.WriteLine("your choice is {0}", rolltype);
if (rolltype = "d4")
{
Console.WriteLine("d4 roll is {0}", d4);
}
else { }
Console.ReadKey();
}
}
}
what i wish to achieve here, is the console asking for the type of roll, and upon being given that, it returns you a random number. The (rolltype = "d4" ) returns an error "cannot implicitly convert type string to bool", and i have no idea how to fix it. Also is there a more elegant way of going at this than writing 6 separate if statements for the rolltypes? Thanks in advance
HankStar
Aucun commentaire:
Enregistrer un commentaire