Static method in c#
static method only contain static data member which is absolutely right. Then Why static method Main() contain non static data member and member function.
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
VulpesRank #55 · 29.2K reputationPosted Dec 18, 2012, 6:55 AM EST
Sharad GuptaRank #111 · 20K reputationPosted Dec 19, 2012, 1:18 AM EST
acutally i was asking to you, if any user defines it own static method.
e.g; user define static method
public static void abc()
{
static int i=1; //correct
int j=10;//incorrect because it is not static member
}
and if i wrote
public static void Main(String [] args)
{
int i=10; //correct
static int j=10;//correct
}
So i am asking to you the user defined abc static method only contain static data member,. if you are initilizing non static data member in it. it will generate a error.
and in Main() it contains both staic and non static data members why?
VulpesRank #55 · 29.2K reputationPosted Dec 19, 2012, 5:18 AM EST