+ 1
What is that "static" thing in c#?
for example " static void func() {statements} "
4 Respuestas
+ 7
C# is a fully object-oriented language, and the Main() method is in a class called Program by default. In order for Main() and other methods to run from this starting class, it must be declared as static.
If none of that makes any sense, don't worry about it! You'll learn more about it later in the course. ^_^ For now, just be sure it's there.
+ 2
Tamra basically hit the nail on the head. While I can't give an exact explanation of static, the later courses will help explain it (especially better than I). I just recently took Java Programming in my college courses, which is similar in syntax (with some minor differences I've noticed to C#), and it's one of the key components of that as well.
+ 1
Main() has to be declared as static because execution starts from there and since it belongs to a class it cannot be accessed otherwise.
Static keyword ensures that function can be accessed from anywhere in the program.
0
main() is static becoz making a method static it can be called without creating instance of a class