+ 1

What does "static" mean in methods

Why do we need to use a static keyword when making a method? static int x() { //return } What is the difference with static and without static?

29th Jun 2017, 10:49 AM
Complex
Complex - avatar
1 Answer
+ 2
When a method is static then it can be invoked directly from the class level without creating an object. This is the reason for making a main() function/method static. Another example is the WriteLine() method that is called/used without creating any object.
29th Jun 2017, 10:58 AM
Kirk Seeger
Kirk Seeger - avatar