小编tag*_*ito的帖子

c#public static string,并非所有代码路径都返回一个值

我完全不了解方法,我不知道为什么会发生这种情况......我试图让我的代码改为单词,我认为这是要走的路.

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            Random r = new Random();
            Console.WriteLine("Hi wanna play rock paper scissors?<press enter to continue>");
            Console.ReadKey();
            int user = 0;
            int ai = r.Next(1, 4);
            Console.WriteLine("Pick what youll show! (1-rock, 2-paper, 3-scissors) and press enter");
            user = Convert.ToInt32(Console.ReadLine());
            if (user > 3)
            {
                Console.WriteLine("ERROR! your number must be <= 3. <Press enter to close the program>");
                goto end;
            }
            if (user == ai)
            {
                Console.WriteLine("Its a draw! <press enter …
Run Code Online (Sandbox Code Playgroud)

c# string return

0
推荐指数
1
解决办法
1099
查看次数

c#否则没有按预期工作

    {
        Random r = new Random();
        int current = 0;
        int noa = 0;
        while (current != 6) {
            current =r.Next(1,7);
                noa += 1;
                Console.WriteLine(current + " has been rolled.");
        }

        if (noa >= 10)
        {
            Console.WriteLine("You were unlucky and it took you "+ noa + " times to roll a 6!");
        }
        if (noa <= 5)
        {
            Console.WriteLine("You were quite lucky and it took you " + noa + " times to roll a 6!");
        }
        else
        {
            Console.WriteLine("It …
Run Code Online (Sandbox Code Playgroud)

c# if-statement while-loop

-3
推荐指数
1
解决办法
1863
查看次数

标签 统计

c# ×2

if-statement ×1

return ×1

string ×1

while-loop ×1