Why does main{} always include a parameter string array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gwainguard@hotmail.com

    #1

    Why does main{} always include a parameter string array?

    Hi from reading the ECMA spec. I know understand that the bracketed
    code after 'void Main' is an instruction that method Main accepts a
    string parameter array.

    Can someone explain to me why this is so? and why by default this
    method always accepts string arguments?

    Indebted for your time,

    GM.


    class Program
    {
    static void Main(string[] args)
    {
    }
    }

  • Roman Wagner

    #2
    Re: Why does main{} always include a parameter string array?


    gwaingu...@hotm ail.com schrieb:
    Can someone explain to me why this is so? and why by default this
    method always accepts string arguments?
    To get programparamete rs from commandline.

    Comment

    • gwainguard@hotmail.com

      #3
      Re: Why does main{} always include a parameter string array?

      Thankyou very much,

      I can see why it is there now and have just written a small program to
      echo the first command line argument and it worked which proves your
      point!

      Many Thanks,

      GM.

      Comment

      • Michael Nemtsev

        #4
        RE: Why does main{} always include a parameter string array?

        It's absolutely not necessary to have params in Main method.
        Take into account that the key instruction not "void Main" but "static Main".

        It has string array because it's the way to get your param from command line

        --
        WBR,
        Michael Nemtsev :: blog: http://spaces.live.com/laflour

        "At times one remains faithful to a cause only because its opponents do not
        cease to be insipid." (c) Friedrich Nietzsche




        "gwainguard@hot mail.com" wrote:
        Hi from reading the ECMA spec. I know understand that the bracketed
        code after 'void Main' is an instruction that method Main accepts a
        string parameter array.
        >
        Can someone explain to me why this is so? and why by default this
        method always accepts string arguments?
        >
        Indebted for your time,
        >
        GM.
        >
        >
        class Program
        {
        static void Main(string[] args)
        {
        }
        }
        >
        >

        Comment

        Working...