+ 1

What is that "static" thing in c#?

for example " static void func() {statements} "

21st Jan 2017, 10:24 PM
arınç alp Eren
arınç alp Eren - avatar
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.
21st Jan 2017, 11:16 PM
Tamra
Tamra - avatar
+ 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.
9th Feb 2017, 6:14 AM
William Draper
William Draper - avatar
+ 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.
9th Feb 2017, 2:50 PM
Ayush Singh
Ayush Singh - avatar
0
main() is static becoz making a method static it can be called without creating instance of a class
10th Feb 2017, 9:02 AM
nikhil yadav
nikhil yadav - avatar