Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 控制台应用程序错误如下:索引(基于零)必须大于或等于零且小于参数列表的大小_C# - Fatal编程技术网

C# 控制台应用程序错误如下:索引(基于零)必须大于或等于零且小于参数列表的大小

C# 控制台应用程序错误如下:索引(基于零)必须大于或等于零且小于参数列表的大小,c#,C#,我将上述内容存储为字符串,并将其传递给processstart(appName,format)。 功能如下。 我在传递参数时遇到了提到的错误 string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\",Id, ProjectId, refresh"; 您的格式字符串看起来像带参数的聚合字符串 将字符串格式更改为: public void ProcessStart(string AppName, string format) {

我将上述内容存储为字符串,并将其传递给processstart(appName,format)。 功能如下。 我在传递参数时遇到了提到的错误

string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\",Id, ProjectId, refresh";

您的
格式字符串
看起来像带参数的聚合字符串

字符串
格式更改为:

public void ProcessStart(string AppName, string format)
    {
        try
        {
            ProcessStartInfo StartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings[AppName].ToString());
            StartInfo.Arguments = string.Format(format);
            StartInfo.CreateNoWindow = true;
            StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(StartInfo);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
然后

string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\";

您的
格式字符串
看起来像带参数的聚合字符串

字符串
格式更改为:

public void ProcessStart(string AppName, string format)
    {
        try
        {
            ProcessStartInfo StartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings[AppName].ToString());
            StartInfo.Arguments = string.Format(format);
            StartInfo.CreateNoWindow = true;
            StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(StartInfo);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
然后

string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\";

您的
格式字符串
看起来像带参数的聚合字符串

字符串
格式更改为:

public void ProcessStart(string AppName, string format)
    {
        try
        {
            ProcessStartInfo StartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings[AppName].ToString());
            StartInfo.Arguments = string.Format(format);
            StartInfo.CreateNoWindow = true;
            StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(StartInfo);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
然后

string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\";

您的
格式字符串
看起来像带参数的聚合字符串

字符串
格式更改为:

public void ProcessStart(string AppName, string format)
    {
        try
        {
            ProcessStartInfo StartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings[AppName].ToString());
            StartInfo.Arguments = string.Format(format);
            StartInfo.CreateNoWindow = true;
            StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(StartInfo);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
然后

string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\";

不能在格式字符串中添加参数,这应该可以:

StartInfo.Arguments = string.Format(format, Id, ProjectId, refresh);

不能在格式字符串中添加参数,这应该可以:

StartInfo.Arguments = string.Format(format, Id, ProjectId, refresh);

不能在格式字符串中添加参数,这应该可以:

StartInfo.Arguments = string.Format(format, Id, ProjectId, refresh);

不能在格式字符串中添加参数,这应该可以:

StartInfo.Arguments = string.Format(format, Id, ProjectId, refresh);

你能显示你正在传递的参数吗?你能显示你正在传递的参数吗?你能显示你正在传递的参数吗?你能显示你正在传递的参数吗?