无法找到C#Static Class

时间:2017-12-07 23:04:00

标签: c# class oop static xna

我创建了一个静态类来保存所有“级别”数组(我正在使用XNA以单一游戏编写游戏)。

问题是我无法在任何地方使用该类,它只会在intellisense中显示,并返回错误The name 'Rooms' does not exist in the current context。知道可能导致这种情况的原因吗?

namespace Marked_V0._2
{
    public static class Rooms
    {
        static public int[,] Level1 = new int[,]
        {
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1 }
        };
    }
}

错误:

CS1002 ; Expected
CS1001 Identifier expected
CS0103 The name 'Rooms' does not exist in the current context.

1 个答案:

答案 0 :(得分:1)

Rooms的命名空间很可能与项目其余部分的命名空间不匹配。您可以更改命名空间,也可以使用using Marked_V0._2包含额外的命名空间。