Issue
Error CS0116 The namespace cannot be implemented in elements such as methods or operators.
11 Replies
Namespace cannot contain fields
Only classes can
move it into the class, c# is not c++, it cannot have members outside class and class must be inside a namespace
Can I have a code example where is it correct?
$structure
For C# versions older than 10, see
$StructureOld
Here's an example of a proper structure
$structureold
For C# versions from 10 onwards, see
$structure
Here it is with the oldschool style namespaces
Why in this place i have a problem?
There's no
OleDbConnection
class
If it's inside of some library or a different namespace in general, you need to import it with a using
statement
Use the quick fixes and VS can do it for you