CS0116 C# A namespace cannot directly contain members, such as fields or methods

Asked

Viewed 1,323 times

3

Good afternoon, I am using VS17 C# and copied the command of another project and is giving error:

CS0116  C# Um namespace não pode conter diretamente membros, como campos ou métodos

error line:

public static DataTable EmpresaPesquisar(global::CamadaModelos.mdlEmpresa _mdlEmpresa)

tried that:

public static DataTable EmpresaPesquisar(CamadaModelos.mdlEmpresa _mdlEmpresa)
  • From what is written, is missing the class of methods.

  • could you elaborate a little bit more ? I’m new and I don’t have that much experience.

1 answer

4

Everything within a project must be contained in a class. Seen, maybe that’s the problem. Involve your methods, properties and variables all in one class.

  • When you take the global:: which error of the?

  • was out of " } " ... :(

  • I’m glad you got the resolution :D

  • It was probably the "}" of the/namespace class. I’m glad you were able to solve the problem.

  • Yes, as stated in the answer, everything within the project, be it a screen, a windows Forms, etc. is within a class. Yes, exactly everything. And if anything stays out of it, it’ll probably make a mistake.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.