“A namespace cannot directly contain members such as fields or methods”
The snippet you’re showing doesn’t seem to be directly responsible for the error. This is how you can CAUSE the error: If you don’t immediately see what is “outside” the class, this may be due to misplaced or extra closing bracket(s) }.