string[] args 如何输入值?
args是程序运行时采用的一个参数,那么如何将值传入。下面示例中怎么出入args的值,可能问题有些弱智,希望大侠们发点时间解答。谢谢。using System; 
public class Factorial 
{
   public static long Fac(long i)
   {
      return ((i <= 1) ? 1 : (i * Fac(i-1)));
   }
}class MainClass 
{
   public static int Main(string[] args) 
   {
      // Test if input arguments were supplied:
      if (args.Length == 0)  
      {
         Console.WriteLine("Please enter a numeric argument."); 
         Console.WriteLine("Usage: Factorial <num>"); 
         return 1; 
      }      // Convert the input arguments to numbers:
      try 
      {
           long num = long.Parse(args[0]); 
           Console.WriteLine("The Factorial of {0} is {1}.",num, Factorial.Fac(num)); 
           return 0;
      }
      catch (System.FormatException)
      {
         Console.WriteLine("Please enter a numeric argument."); 
         Console.WriteLine("Usage: Factorial <num>"); 
         return 1; 
      }
   }
}

解决方案 »

  1.   


    string[] csdn={"a","b"};
    Main(csdn);
      

  2.   

    比方你成程序名称a.exe,那么你的程序运行参数就是的,如:a.exe 1 2 3
    那么:args={1,2,3}
      

  3.   

    2楼正解,你之后就可以把程序的参数转化为对数组args的处理,这样楼主应该没什么问题吧?
      

  4.   

    a.exe 1 2 3这个参数在哪里输入?
    命令行?
      

  5.   

    命令行 cmd
    D:\ a 1 2 3
    快捷方式 新建a的快捷方式---------->属性----------->
    "D:\a.exe"
    改成
    "D:\a.exe" 1 2 3
    进程:
                Process p = new Process();
                ProcessStartInfo ps = new ProcessStartInfo("FileName", "1 2 3");
                p.StartInfo = ps;
                p.Start();