Entry is throwing errors
This question already has an answer here:
The other answers are correct (the compiler does not let you pass a string as an argument to a method expecting a string array), but an alternative approach is to change the method signature of your Main
method like so:
static void Main(params string[] arg)
The params
keyword allows arguments to be passed in separately instead of an array. Thus, the following calls would be equivalent:
Main("month");
Main(new string[] {"month"});
Incidentally -- while it is legal, it is not common to call the Main
method (your program's entry point) from your own program. Depending on your requirements, you may want to consider a new method that has only a single string as an argument, eg:
public static void MyMethod(string s)
{
// your code
}
// in your Main method
MyMethod("month");
String is one String. String[]
is an array of Strings.
Try this:
String[] parameters = new String[] {"month"};
Main(parameters);
See http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx for more information about arrays and declaring/instantiating them.
链接地址: http://www.djcxy.com/p/89834.html上一篇: TryParse无效参数
下一篇: 输入发生错误