c# – A namespace cannot directly contain members such as fields or methods
c# – A namespace cannot directly contain members such as fields or methods
The snippet youre showing doesnt seem to be directly responsible for the error.
This is how you can CAUSE the error:
namespace MyNameSpace
{
int i; <-- THIS NEEDS TO BE INSIDE THE CLASS
class MyClass
{
...
}
}
If you dont immediately see what is outside the class, this may be due to misplaced or extra closing bracket(s) }
.