Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.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# CS1503 Argument1:无法从';字符串';至';字符串[*,*]和#x27;_C#_Winforms - Fatal编程技术网

C# CS1503 Argument1:无法从';字符串';至';字符串[*,*]和#x27;

C# CS1503 Argument1:无法从';字符串';至';字符串[*,*]和#x27;,c#,winforms,C#,Winforms,我是初学者。方法GetFullName()的参数“brnd”和“nm”似乎是错误的罪魁祸首- CS1503 Argument1(和Argument2):无法从“字符串”转换为 “字符串[,]” 有人能解释一下这个问题以及如何解决它吗?非常感谢你 if (iteminfo[row, 0] == serialcheck) { brnd = iteminfo[row, 1];

我是初学者。方法GetFullName()的参数“brnd”和“nm”似乎是错误的罪魁祸首-

CS1503 Argument1(和Argument2):无法从“字符串”转换为 “字符串[,]”

有人能解释一下这个问题以及如何解决它吗?非常感谢你

                if (iteminfo[row, 0] == serialcheck)
                {
                    brnd = iteminfo[row, 1];
                    nm = iteminfo[row, 2];

                    info = GetFullName(brnd,nm);
                    
                    MessageBox.Show(info);

                    return;
                }

                

    public string GetFullName(string[,] brandp, string[,] namep )
    {
        fullname = brandp + " - " + namep;
        return fullname;
    }

方法
GetFullName
显然旨在对
string
值进行操作,但您已将参数声明为
string
类型的二维数组,并将
string
值作为参数传递-

info = GetFullName(brnd,nm);
这就是错误的根源

将方法签名修改为-

public string GetFullName(string brandp, string namep )
{
    var fullname = brandp + " - " + namep;
    return fullname;
}

你在哪一行收到错误?信息的类型是什么?
iteminfo
的类型是什么?另外,
brandp+“-”+namep
将为非空值生成“System.String[,]-System.String[,]”。