gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
what's wrong with this C# Code, how do I fix it so it runs?: using System; namespace…
- User
what's wrong with this C# Code, how do I fix it so it runs?: using System;
namespace Prog;
class GuessGame { static void Main(string[] args) {
}
void Rolling() { Random r = new Random(); int res = r.Next( 45); Console.WriteLine("Roll the Dice!"); String Roll = Console.ReadLine();
codeif (Roll == "Roll") { Console.WriteLine(res); } Console.ReadKey(); RollDice();}
void RollDice() { Random r = new Random(); int res = r.Next( 45); Console.WriteLine("Roll the Dice!"); String Roll = Console.ReadLine();
codeif (Roll == "Roll") { Console.WriteLine(res); } Console.ReadKey(); Rolling();} }
- Assistant
It seems like you want to have a simple program that rolls a dice when the user types "Roll". You have two methods (
Rolling()andRollDice()) that basically do the same thing. I will simplify the code by using just one method.Here's the corrected code:
csharp