C# - Calling a function from static main

后端 未结 2 944
野趣味
野趣味 2021-01-24 09:03

my question is probably very basic but I did not find an answer...

I wrote a function (public checkSomething that gets 2 strings) in program.cs when I tried to call this

2条回答
  •  走了就别回头了
    2021-01-24 09:43

    Main method should be static so you can't call non static methods from static method.

    change checkSomething to static.

    if main method is not static then we need to create instance to call the main method. To create instant again we need to excute some code! Thats why I think this starting point Main make Static.

提交回复
热议问题