且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“名称空间不能直接包含诸如字段或方法之类的成员".

更新时间:2023-02-20 10:56:10

您显示的摘录似乎与错误无关.

The snippet you're showing doesn't seem to be directly responsible for the error.

这是导致错误的方法:

namespace MyNameSpace
{
   int i; <-- THIS NEEDS TO BE INSIDE THE CLASS

   class MyClass
   {
      ...
   }
}

如果您没有立即看到班级之外"的内容,则可能是由于放错位置或多余的右方括号} .

If you don't immediately see what is "outside" the class, this may be due to misplaced or extra closing bracket(s) }.