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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Bruce Roeser47 reputationPosted Jul 17, 2010, 9:36 AM EDT
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-
Sam HobbsRank #107 · 20.5K reputationPosted Jul 17, 2010, 12:13 PM EDT
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.
Dipa AhujaRank #1,168 · 1.5K reputationPosted Jul 18, 2010, 4:57 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Jul 18, 2010, 1:02 PM EDT