whenever we create console application we get the code like
static void Main(string[] args)
{
}
any one can tell me the meaning of static here? why the static key word is used? and what it mean?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jul 18, 2010, 5:02 PM
Dipa AhujaPosted Jul 18, 2010, 8:57 AM
Sam HobbsPosted Jul 17, 2010, 4:13 PM
Note that this question is essentially the same as your what is shared void main and void main?. It is better to not ask the same question more than once because people might answer a question that already has answers elsewhere. I might choose to ignore questions when I see duplicates.
Bruce RoeserPosted Jul 17, 2010, 1:36 PM
For example, let's say you defined a class:
class foo {
public static void bar() {
}
}
bar() is called a class method because you can call it without creating an instance of foo. I.E.
foo.bar();
However, if you left 'static' off, then you would have to create an instance of the class to use the function:
foo f = new foo();
f.bar();
HTH,
-bwr-