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.
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.
VulpesPosted Dec 19, 2012, 10:18 AM
Sharad GuptaPosted Dec 19, 2012, 6:18 AM
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?
VulpesPosted Dec 18, 2012, 11:55 AM