Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Why is it static?

Question posted by: lordango (Newbie) on July 25th, 2008 04:59 AM
Can someone explain to me what static is and why is main function declared as static.

and how come I cannot call a function declared as private.


static void Main(string[] args)
{
...
pFunction();
}

private void pFunction()
{
code.....
}
r035198x's Avatar
r035198x
Administrator
10,756 Posts
July 25th, 2008
06:10 AM
#2

Re: Why is it static?
The best thing here is to get a C# tutorial and read it.

Reply
lordango's Avatar
lordango
Newbie
14 Posts
July 25th, 2008
08:06 AM
#3

Re: Why is it static?
thanks for helping. you were great!

Reply
Plater's Avatar
Plater
Moderator
5,608 Posts
July 28th, 2008
02:23 PM
#4

Re: Why is it static?
Quote:
thanks for helping. you were great!

I thought so too. His answer was direct and had exactly the information you needed. Good Work.

Reply
shahidnoor86's Avatar
shahidnoor86
Newbie
3 Posts
July 29th, 2008
04:19 AM
#5

Re: Why is it static?
what the name specifies, static is Fixed. When we use this in a loop like

For i As Integer = 0 To 4
Static p As Integer = 0
p = p + 1
Next

the value of p does not initialize again and again. After the loop the value of p will be 5.

Reply
lordango's Avatar
lordango
Newbie
14 Posts
July 29th, 2008
03:03 PM
#6

Re: Why is it static?
what i want to know is why should main be static?

is it because you can call static without instantiating thus making the main/entry point of the program available?

Reply
Plater's Avatar
Plater
Moderator
5,608 Posts
July 29th, 2008
03:09 PM
#7

Re: Why is it static?
Quote:
what i want to know is why should main be static?

is it because you can call static without instantiating thus making the main/entry point of the program available?

Yes .

Reply
Reply
Not the answer you were looking for? Post your question . . .
190,475 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top .NET Forum Contributors