Error CS0116: A namespace cannot directly contain members such as fields or methods

后端 未结 1 1068
情书的邮戳
情书的邮戳 2021-01-28 19:22

Ok so im trying to make a program that checks if a program is currently running. It is giving me a error when ever i declare a void. I am new to C# so im sorry if its a stupid.<

相关标签:
1条回答
  • 2021-01-28 19:32

    To have instance members and methods, you need a class. You have confused a namespace with a class

    namespace MyAwesomeNameSpace
    {
       public class ProgramRunningHelper
       {
           // put your class code here
    
       }
    }
    

    Compiler Error CS0116

    A namespace cannot directly contain members such as fields or methods.

    A namespace can contain other namespaces, structs, and classes.

    0 讨论(0)
提交回复
热议问题