not all code paths return a “value”

后端 未结 2 920
逝去的感伤
逝去的感伤 2021-01-29 15:47

Hi I am trying to make a mastermind game where I having the user guess a number sequence between 4-10 instead of colours but for some reason my GetRandomNumberCount and my Gener

2条回答
  •  隐瞒了意图╮
    2021-01-29 16:23

    You are getting that error cause your method signature says it returns a int but your are not returning anything. What I see is, you meant to have a method with void return type like below since you are just printing the lines

    public static void GetRandomNumberCount()
    {
          //Create the secret code
          Random RandomClass = new Random();
    
          int first = RandomClass.Next(1, 5);
          int second = RandomClass.Next(1,5);
          int third = RandomClass.Next(1,5);
          int forth = RandomClass.Next(1,5);
    
          Console.WriteLine ("You are playing with M@sterB@t");
          Console.WriteLine ("Bot Says : You Go First");
          Console.WriteLine("Game Settings ");
          Console.WriteLine("The Game Begins");
    }
    

提交回复
热议问题