Why is it static?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lordango
    New Member
    • Jul 2008
    • 14

    Why is it static?

    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
    MVP
    • Sep 2006
    • 13225

    #2
    The best thing here is to get a C# tutorial and read it.

    Comment

    • lordango
      New Member
      • Jul 2008
      • 14

      #3
      thanks for helping. you were great!

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Originally posted by lordango
        thanks for helping. you were great!
        I thought so too. His answer was direct and had exactly the information you needed. Good Work.

        Comment

        • shahidnoor86
          New Member
          • Jul 2008
          • 3

          #5
          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.

          Comment

          • lordango
            New Member
            • Jul 2008
            • 14

            #6
            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?

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Originally posted by lordango
              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 .

              Comment

              Working...