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