本文介绍了(C#"Random"是一个命名空间,但像一个变量一样使用)我不明白为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Welcome To The Random.");
        System.Threading.Thread.Sleep(1000);

        choosing:

        Console.WriteLine("Roll Standard Dice (D), Flip a Coin (2), 8-Ball (8), or Random Number 1-10 (R)");

        ConsoleKeyInfo result = Console.ReadKey();
        if ((result.KeyChar == 'D') || (result.KeyChar == 'd'))
        {
            Console.WriteLine("Standard Dice Has been chosen, do you want to continue? Y/N");
            ConsoleKeyInfo RSD = Console.ReadKey();

            if ((RSD.KeyChar == 'Y') || (RSD.KeyChar == 'y'))
            {
                Console.Write("Rolling");
                Console.Write(".");
                Console.Write(".");
                Console.Write(".");
            }
            else if ((RSD.KeyChar == 'N') || (RSD.KeyChar == 'n'))
            {
                Console.Clear();
                goto choosing;
            }
        }
        else if ((result.KeyChar == '2'))
        {
            Console.WriteLine("I wont do anything");
        }
        else if ((result.KeyChar == '8'))
        {
        }
        else if ((result.KeyChar == 'R') || (result.KeyChar == 'r'))
        {
        }

        *Random* rnd = new *Random*();
    }
}

asterix中的部分是红线,它表示Random是一个名称空间,但它像一个变量一样使用.随机的东西通常可以正常工作,但是我不确定为什么现在不能正常工作,如果可以的话请帮助我.

The parts in asterix are the part where it is a red line and it says Random is a namespace but it's used like a variable. The Random thing normally works but I'm not sure why it isn't working now if you could please help me that would be appreciated.

推荐答案

您的项目的命名空间也是Random,将其更改为其他名称,

Your project's namespace is also Random, change it to some other name,

命名空间随机

namespace Random

命名空间示例

namespace Sample

这篇关于(C#"Random"是一个命名空间,但像一个变量一样使用)我不明白为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 06:04