tags:

views:

61

answers:

4

Hi My practice code

using System;
using System.Collections.Generic;
using System.Text;

namespace MyConApp
{
    class Program
    {
        static void Main(string[] args) 
        {
            string[] tmpString; 
            tmpString = args;
            Console.WriteLine("Hello" + tmpString[0].ToString());
        }
    }
}

Why The expression below show compiling error message "does not contain a static 'Main' method suitable for an entry point"

namespace MyConApp
{
    class Program
    {
        static void Main(string args) 
        {
            string tmpString; 
            tmpString = args;
            Console.WriteLine("Hello" + tmpString);
        }
    }
}

Thank you.

+1  A: 

The signature of the main method must be main(String[]), not main(String).

matt b
+2  A: 

Because the argument is String and not a String Array as expected

Sands
+1  A: 

See this to understand Main method signature options.

shahkalpesh
+2  A: 

The only valid signatures for Main method are :

static void Main()

and

static void Main(string[])

static void Main(string) is not a valid signature for Main method.

missingfaktor
Actually return type may also be int instead of void.
Cloudanger