找不到C#静态类
我创建了一个静态类来保存我所有的“级别”数组(我正在用XNA编写一个monogame游戏) 问题是我不能在任何地方使用该类,它只是不会在intellisense中显示,并返回一个错误找不到C#静态类,c#,class,oop,static,xna,C#,Class,Oop,Static,Xna,我创建了一个静态类来保存我所有的“级别”数组(我正在用XNA编写一个monogame游戏) 问题是我不能在任何地方使用该类,它只是不会在intellisense中显示,并返回一个错误当前上下文中不存在名称“Rooms”。你知道这是什么原因吗 namespace Marked_V0._2 { public static class Rooms { static public int[,] Level1 = new int[,] {
当前上下文中不存在名称“Rooms”
。你知道这是什么原因吗
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.
文件室的命名空间
很可能与项目其余部分的命名空间不匹配。您可以更改名称空间,也可以使用标记的\u V0将额外的名称空间包含在中。\u 2
检查您的名称空间。无论您想在何处使用此类,都可以在该类中使用标记的\u V0将其写入名称空间上方的类顶部:使用标记的\u V0。\u 2
另外,在旁注中,它返回的是int[,]
而不是int
,因此请注意分配给它的内容。